documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049
  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. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** 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 */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** 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 */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** 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 */
  684. static readonly GEQUAL: number;
  685. /** 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 */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * 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.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * 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.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. 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>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. 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;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * 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".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * 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"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * 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"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * 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)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @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
  4923. * @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
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5780. * @returns a string containing the hexadecimal representation of the Color4 object
  5781. */
  5782. toHexString(returnAsColor3?: boolean): string;
  5783. /**
  5784. * Computes a new Color4 converted from the current one to linear space
  5785. * @returns a new Color4 object
  5786. */
  5787. toLinearSpace(): Color4;
  5788. /**
  5789. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5790. * @param convertedColor defines the Color4 object where to store the linear space version
  5791. * @returns the unmodified Color4
  5792. */
  5793. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5794. /**
  5795. * Computes a new Color4 converted from the current one to gamma space
  5796. * @returns a new Color4 object
  5797. */
  5798. toGammaSpace(): Color4;
  5799. /**
  5800. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5801. * @param convertedColor defines the Color4 object where to store the gamma space version
  5802. * @returns the unmodified Color4
  5803. */
  5804. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5805. /**
  5806. * Creates a new Color4 from the string containing valid hexadecimal values
  5807. * @param hex defines a string containing valid hexadecimal values
  5808. * @returns a new Color4 object
  5809. */
  5810. static FromHexString(hex: string): Color4;
  5811. /**
  5812. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5813. * @param left defines the start value
  5814. * @param right defines the end value
  5815. * @param amount defines the gradient factor
  5816. * @returns a new Color4 object
  5817. */
  5818. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5819. /**
  5820. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5821. * @param left defines the start value
  5822. * @param right defines the end value
  5823. * @param amount defines the gradient factor
  5824. * @param result defines the Color4 object where to store data
  5825. */
  5826. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5827. /**
  5828. * Creates a new Color4 from a Color3 and an alpha value
  5829. * @param color3 defines the source Color3 to read from
  5830. * @param alpha defines the alpha component (1.0 by default)
  5831. * @returns a new Color4 object
  5832. */
  5833. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5834. /**
  5835. * Creates a new Color4 from the starting index element of the given array
  5836. * @param array defines the source array to read from
  5837. * @param offset defines the offset in the source array
  5838. * @returns a new Color4 object
  5839. */
  5840. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5841. /**
  5842. * Creates a new Color3 from integer values (< 256)
  5843. * @param r defines the red component to read from (value between 0 and 255)
  5844. * @param g defines the green component to read from (value between 0 and 255)
  5845. * @param b defines the blue component to read from (value between 0 and 255)
  5846. * @param a defines the alpha component to read from (value between 0 and 255)
  5847. * @returns a new Color3 object
  5848. */
  5849. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5850. /**
  5851. * Check the content of a given array and convert it to an array containing RGBA data
  5852. * If the original array was already containing count * 4 values then it is returned directly
  5853. * @param colors defines the array to check
  5854. * @param count defines the number of RGBA data to expect
  5855. * @returns an array containing count * 4 values (RGBA)
  5856. */
  5857. static CheckColors4(colors: number[], count: number): number[];
  5858. }
  5859. /**
  5860. * @hidden
  5861. */
  5862. export class TmpColors {
  5863. static Color3: Color3[];
  5864. static Color4: Color4[];
  5865. }
  5866. }
  5867. declare module BABYLON {
  5868. /**
  5869. * Defines an interface which represents an animation key frame
  5870. */
  5871. export interface IAnimationKey {
  5872. /**
  5873. * Frame of the key frame
  5874. */
  5875. frame: number;
  5876. /**
  5877. * Value at the specifies key frame
  5878. */
  5879. value: any;
  5880. /**
  5881. * The input tangent for the cubic hermite spline
  5882. */
  5883. inTangent?: any;
  5884. /**
  5885. * The output tangent for the cubic hermite spline
  5886. */
  5887. outTangent?: any;
  5888. /**
  5889. * The animation interpolation type
  5890. */
  5891. interpolation?: AnimationKeyInterpolation;
  5892. }
  5893. /**
  5894. * Enum for the animation key frame interpolation type
  5895. */
  5896. export enum AnimationKeyInterpolation {
  5897. /**
  5898. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5899. */
  5900. STEP = 1
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. /**
  5905. * Represents the range of an animation
  5906. */
  5907. export class AnimationRange {
  5908. /**The name of the animation range**/
  5909. name: string;
  5910. /**The starting frame of the animation */
  5911. from: number;
  5912. /**The ending frame of the animation*/
  5913. to: number;
  5914. /**
  5915. * Initializes the range of an animation
  5916. * @param name The name of the animation range
  5917. * @param from The starting frame of the animation
  5918. * @param to The ending frame of the animation
  5919. */
  5920. constructor(
  5921. /**The name of the animation range**/
  5922. name: string,
  5923. /**The starting frame of the animation */
  5924. from: number,
  5925. /**The ending frame of the animation*/
  5926. to: number);
  5927. /**
  5928. * Makes a copy of the animation range
  5929. * @returns A copy of the animation range
  5930. */
  5931. clone(): AnimationRange;
  5932. }
  5933. }
  5934. declare module BABYLON {
  5935. /**
  5936. * Composed of a frame, and an action function
  5937. */
  5938. export class AnimationEvent {
  5939. /** The frame for which the event is triggered **/
  5940. frame: number;
  5941. /** The event to perform when triggered **/
  5942. action: (currentFrame: number) => void;
  5943. /** Specifies if the event should be triggered only once**/
  5944. onlyOnce?: boolean | undefined;
  5945. /**
  5946. * Specifies if the animation event is done
  5947. */
  5948. isDone: boolean;
  5949. /**
  5950. * Initializes the animation event
  5951. * @param frame The frame for which the event is triggered
  5952. * @param action The event to perform when triggered
  5953. * @param onlyOnce Specifies if the event should be triggered only once
  5954. */
  5955. constructor(
  5956. /** The frame for which the event is triggered **/
  5957. frame: number,
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void,
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined);
  5962. /** @hidden */
  5963. _clone(): AnimationEvent;
  5964. }
  5965. }
  5966. declare module BABYLON {
  5967. /**
  5968. * Interface used to define a behavior
  5969. */
  5970. export interface Behavior<T> {
  5971. /** gets or sets behavior's name */
  5972. name: string;
  5973. /**
  5974. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5975. */
  5976. init(): void;
  5977. /**
  5978. * Called when the behavior is attached to a target
  5979. * @param target defines the target where the behavior is attached to
  5980. */
  5981. attach(target: T): void;
  5982. /**
  5983. * Called when the behavior is detached from its target
  5984. */
  5985. detach(): void;
  5986. }
  5987. /**
  5988. * Interface implemented by classes supporting behaviors
  5989. */
  5990. export interface IBehaviorAware<T> {
  5991. /**
  5992. * Attach a behavior
  5993. * @param behavior defines the behavior to attach
  5994. * @returns the current host
  5995. */
  5996. addBehavior(behavior: Behavior<T>): T;
  5997. /**
  5998. * Remove a behavior from the current object
  5999. * @param behavior defines the behavior to detach
  6000. * @returns the current host
  6001. */
  6002. removeBehavior(behavior: Behavior<T>): T;
  6003. /**
  6004. * Gets a behavior using its name to search
  6005. * @param name defines the name to search
  6006. * @returns the behavior or null if not found
  6007. */
  6008. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * Defines an array and its length.
  6014. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6015. */
  6016. export interface ISmartArrayLike<T> {
  6017. /**
  6018. * The data of the array.
  6019. */
  6020. data: Array<T>;
  6021. /**
  6022. * The active length of the array.
  6023. */
  6024. length: number;
  6025. }
  6026. /**
  6027. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6028. */
  6029. export class SmartArray<T> implements ISmartArrayLike<T> {
  6030. /**
  6031. * The full set of data from the array.
  6032. */
  6033. data: Array<T>;
  6034. /**
  6035. * The active length of the array.
  6036. */
  6037. length: number;
  6038. protected _id: number;
  6039. /**
  6040. * Instantiates a Smart Array.
  6041. * @param capacity defines the default capacity of the array.
  6042. */
  6043. constructor(capacity: number);
  6044. /**
  6045. * Pushes a value at the end of the active data.
  6046. * @param value defines the object to push in the array.
  6047. */
  6048. push(value: T): void;
  6049. /**
  6050. * Iterates over the active data and apply the lambda to them.
  6051. * @param func defines the action to apply on each value.
  6052. */
  6053. forEach(func: (content: T) => void): void;
  6054. /**
  6055. * Sorts the full sets of data.
  6056. * @param compareFn defines the comparison function to apply.
  6057. */
  6058. sort(compareFn: (a: T, b: T) => number): void;
  6059. /**
  6060. * Resets the active data to an empty array.
  6061. */
  6062. reset(): void;
  6063. /**
  6064. * Releases all the data from the array as well as the array.
  6065. */
  6066. dispose(): void;
  6067. /**
  6068. * Concats the active data with a given array.
  6069. * @param array defines the data to concatenate with.
  6070. */
  6071. concat(array: any): void;
  6072. /**
  6073. * Returns the position of a value in the active data.
  6074. * @param value defines the value to find the index for
  6075. * @returns the index if found in the active data otherwise -1
  6076. */
  6077. indexOf(value: T): number;
  6078. /**
  6079. * Returns whether an element is part of the active data.
  6080. * @param value defines the value to look for
  6081. * @returns true if found in the active data otherwise false
  6082. */
  6083. contains(value: T): boolean;
  6084. private static _GlobalId;
  6085. }
  6086. /**
  6087. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6088. * The data in this array can only be present once
  6089. */
  6090. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6091. private _duplicateId;
  6092. /**
  6093. * Pushes a value at the end of the active data.
  6094. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6095. * @param value defines the object to push in the array.
  6096. */
  6097. push(value: T): void;
  6098. /**
  6099. * Pushes a value at the end of the active data.
  6100. * If the data is already present, it won t be added again
  6101. * @param value defines the object to push in the array.
  6102. * @returns true if added false if it was already present
  6103. */
  6104. pushNoDuplicate(value: T): boolean;
  6105. /**
  6106. * Resets the active data to an empty array.
  6107. */
  6108. reset(): void;
  6109. /**
  6110. * Concats the active data with a given array.
  6111. * This ensures no dupplicate will be present in the result.
  6112. * @param array defines the data to concatenate with.
  6113. */
  6114. concatWithNoDuplicate(array: any): void;
  6115. }
  6116. }
  6117. declare module BABYLON {
  6118. /**
  6119. * @ignore
  6120. * This is a list of all the different input types that are available in the application.
  6121. * Fo instance: ArcRotateCameraGamepadInput...
  6122. */
  6123. export var CameraInputTypes: {};
  6124. /**
  6125. * This is the contract to implement in order to create a new input class.
  6126. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6127. */
  6128. export interface ICameraInput<TCamera extends Camera> {
  6129. /**
  6130. * Defines the camera the input is attached to.
  6131. */
  6132. camera: Nullable<TCamera>;
  6133. /**
  6134. * Gets the class name of the current intput.
  6135. * @returns the class name
  6136. */
  6137. getClassName(): string;
  6138. /**
  6139. * Get the friendly name associated with the input class.
  6140. * @returns the input friendly name
  6141. */
  6142. getSimpleName(): string;
  6143. /**
  6144. * Attach the input controls to a specific dom element to get the input from.
  6145. * @param element Defines the element the controls should be listened from
  6146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6147. */
  6148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6149. /**
  6150. * Detach the current controls from the specified dom element.
  6151. * @param element Defines the element to stop listening the inputs from
  6152. */
  6153. detachControl(element: Nullable<HTMLElement>): void;
  6154. /**
  6155. * Update the current camera state depending on the inputs that have been used this frame.
  6156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6157. */
  6158. checkInputs?: () => void;
  6159. }
  6160. /**
  6161. * Represents a map of input types to input instance or input index to input instance.
  6162. */
  6163. export interface CameraInputsMap<TCamera extends Camera> {
  6164. /**
  6165. * Accessor to the input by input type.
  6166. */
  6167. [name: string]: ICameraInput<TCamera>;
  6168. /**
  6169. * Accessor to the input by input index.
  6170. */
  6171. [idx: number]: ICameraInput<TCamera>;
  6172. }
  6173. /**
  6174. * This represents the input manager used within a camera.
  6175. * It helps dealing with all the different kind of input attached to a camera.
  6176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6177. */
  6178. export class CameraInputsManager<TCamera extends Camera> {
  6179. /**
  6180. * Defines the list of inputs attahed to the camera.
  6181. */
  6182. attached: CameraInputsMap<TCamera>;
  6183. /**
  6184. * Defines the dom element the camera is collecting inputs from.
  6185. * This is null if the controls have not been attached.
  6186. */
  6187. attachedElement: Nullable<HTMLElement>;
  6188. /**
  6189. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. noPreventDefault: boolean;
  6192. /**
  6193. * Defined the camera the input manager belongs to.
  6194. */
  6195. camera: TCamera;
  6196. /**
  6197. * Update the current camera state depending on the inputs that have been used this frame.
  6198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6199. */
  6200. checkInputs: () => void;
  6201. /**
  6202. * Instantiate a new Camera Input Manager.
  6203. * @param camera Defines the camera the input manager blongs to
  6204. */
  6205. constructor(camera: TCamera);
  6206. /**
  6207. * Add an input method to a camera
  6208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6209. * @param input camera input method
  6210. */
  6211. add(input: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Remove a specific input method from a camera
  6214. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6215. * @param inputToRemove camera input method
  6216. */
  6217. remove(inputToRemove: ICameraInput<TCamera>): void;
  6218. /**
  6219. * Remove a specific input type from a camera
  6220. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6221. * @param inputType the type of the input to remove
  6222. */
  6223. removeByType(inputType: string): void;
  6224. private _addCheckInputs;
  6225. /**
  6226. * Attach the input controls to the currently attached dom element to listen the events from.
  6227. * @param input Defines the input to attach
  6228. */
  6229. attachInput(input: ICameraInput<TCamera>): void;
  6230. /**
  6231. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6232. * @param element Defines the dom element to collect the events from
  6233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6234. */
  6235. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6236. /**
  6237. * Detach the current manager inputs controls from a specific dom element.
  6238. * @param element Defines the dom element to collect the events from
  6239. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6240. */
  6241. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6242. /**
  6243. * Rebuild the dynamic inputCheck function from the current list of
  6244. * defined inputs in the manager.
  6245. */
  6246. rebuildInputCheck(): void;
  6247. /**
  6248. * Remove all attached input methods from a camera
  6249. */
  6250. clear(): void;
  6251. /**
  6252. * Serialize the current input manager attached to a camera.
  6253. * This ensures than once parsed,
  6254. * the input associated to the camera will be identical to the current ones
  6255. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6256. */
  6257. serialize(serializedCamera: any): void;
  6258. /**
  6259. * Parses an input manager serialized JSON to restore the previous list of inputs
  6260. * and states associated to a camera.
  6261. * @param parsedCamera Defines the JSON to parse
  6262. */
  6263. parse(parsedCamera: any): void;
  6264. }
  6265. }
  6266. declare module BABYLON {
  6267. /**
  6268. * Class used to store data that will be store in GPU memory
  6269. */
  6270. export class Buffer {
  6271. private _engine;
  6272. private _buffer;
  6273. /** @hidden */
  6274. _data: Nullable<DataArray>;
  6275. private _updatable;
  6276. private _instanced;
  6277. private _divisor;
  6278. /**
  6279. * Gets the byte stride.
  6280. */
  6281. readonly byteStride: number;
  6282. /**
  6283. * Constructor
  6284. * @param engine the engine
  6285. * @param data the data to use for this buffer
  6286. * @param updatable whether the data is updatable
  6287. * @param stride the stride (optional)
  6288. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6289. * @param instanced whether the buffer is instanced (optional)
  6290. * @param useBytes set to true if the stride in in bytes (optional)
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. */
  6293. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6294. /**
  6295. * Create a new VertexBuffer based on the current buffer
  6296. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6297. * @param offset defines offset in the buffer (0 by default)
  6298. * @param size defines the size in floats of attributes (position is 3 for instance)
  6299. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6300. * @param instanced defines if the vertex buffer contains indexed data
  6301. * @param useBytes defines if the offset and stride are in bytes *
  6302. * @param divisor sets an optional divisor for instances (1 by default)
  6303. * @returns the new vertex buffer
  6304. */
  6305. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6306. /**
  6307. * Gets a boolean indicating if the Buffer is updatable?
  6308. * @returns true if the buffer is updatable
  6309. */
  6310. isUpdatable(): boolean;
  6311. /**
  6312. * Gets current buffer's data
  6313. * @returns a DataArray or null
  6314. */
  6315. getData(): Nullable<DataArray>;
  6316. /**
  6317. * Gets underlying native buffer
  6318. * @returns underlying native buffer
  6319. */
  6320. getBuffer(): Nullable<DataBuffer>;
  6321. /**
  6322. * Gets the stride in float32 units (i.e. byte stride / 4).
  6323. * May not be an integer if the byte stride is not divisible by 4.
  6324. * @returns the stride in float32 units
  6325. * @deprecated Please use byteStride instead.
  6326. */
  6327. getStrideSize(): number;
  6328. /**
  6329. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6330. * @param data defines the data to store
  6331. */
  6332. create(data?: Nullable<DataArray>): void;
  6333. /** @hidden */
  6334. _rebuild(): void;
  6335. /**
  6336. * Update current buffer data
  6337. * @param data defines the data to store
  6338. */
  6339. update(data: DataArray): void;
  6340. /**
  6341. * Updates the data directly.
  6342. * @param data the new data
  6343. * @param offset the new offset
  6344. * @param vertexCount the vertex count (optional)
  6345. * @param useBytes set to true if the offset is in bytes
  6346. */
  6347. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6348. /**
  6349. * Release all resources
  6350. */
  6351. dispose(): void;
  6352. }
  6353. /**
  6354. * Specialized buffer used to store vertex data
  6355. */
  6356. export class VertexBuffer {
  6357. /** @hidden */
  6358. _buffer: Buffer;
  6359. private _kind;
  6360. private _size;
  6361. private _ownsBuffer;
  6362. private _instanced;
  6363. private _instanceDivisor;
  6364. /**
  6365. * The byte type.
  6366. */
  6367. static readonly BYTE: number;
  6368. /**
  6369. * The unsigned byte type.
  6370. */
  6371. static readonly UNSIGNED_BYTE: number;
  6372. /**
  6373. * The short type.
  6374. */
  6375. static readonly SHORT: number;
  6376. /**
  6377. * The unsigned short type.
  6378. */
  6379. static readonly UNSIGNED_SHORT: number;
  6380. /**
  6381. * The integer type.
  6382. */
  6383. static readonly INT: number;
  6384. /**
  6385. * The unsigned integer type.
  6386. */
  6387. static readonly UNSIGNED_INT: number;
  6388. /**
  6389. * The float type.
  6390. */
  6391. static readonly FLOAT: number;
  6392. /**
  6393. * Gets or sets the instance divisor when in instanced mode
  6394. */
  6395. get instanceDivisor(): number;
  6396. set instanceDivisor(value: number);
  6397. /**
  6398. * Gets the byte stride.
  6399. */
  6400. readonly byteStride: number;
  6401. /**
  6402. * Gets the byte offset.
  6403. */
  6404. readonly byteOffset: number;
  6405. /**
  6406. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6407. */
  6408. readonly normalized: boolean;
  6409. /**
  6410. * Gets the data type of each component in the array.
  6411. */
  6412. readonly type: number;
  6413. /**
  6414. * Constructor
  6415. * @param engine the engine
  6416. * @param data the data to use for this vertex buffer
  6417. * @param kind the vertex buffer kind
  6418. * @param updatable whether the data is updatable
  6419. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6420. * @param stride the stride (optional)
  6421. * @param instanced whether the buffer is instanced (optional)
  6422. * @param offset the offset of the data (optional)
  6423. * @param size the number of components (optional)
  6424. * @param type the type of the component (optional)
  6425. * @param normalized whether the data contains normalized data (optional)
  6426. * @param useBytes set to true if stride and offset are in bytes (optional)
  6427. * @param divisor defines the instance divisor to use (1 by default)
  6428. */
  6429. 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);
  6430. /** @hidden */
  6431. _rebuild(): void;
  6432. /**
  6433. * Returns the kind of the VertexBuffer (string)
  6434. * @returns a string
  6435. */
  6436. getKind(): string;
  6437. /**
  6438. * Gets a boolean indicating if the VertexBuffer is updatable?
  6439. * @returns true if the buffer is updatable
  6440. */
  6441. isUpdatable(): boolean;
  6442. /**
  6443. * Gets current buffer's data
  6444. * @returns a DataArray or null
  6445. */
  6446. getData(): Nullable<DataArray>;
  6447. /**
  6448. * Gets underlying native buffer
  6449. * @returns underlying native buffer
  6450. */
  6451. getBuffer(): Nullable<DataBuffer>;
  6452. /**
  6453. * Gets the stride in float32 units (i.e. byte stride / 4).
  6454. * May not be an integer if the byte stride is not divisible by 4.
  6455. * @returns the stride in float32 units
  6456. * @deprecated Please use byteStride instead.
  6457. */
  6458. getStrideSize(): number;
  6459. /**
  6460. * Returns the offset as a multiple of the type byte length.
  6461. * @returns the offset in bytes
  6462. * @deprecated Please use byteOffset instead.
  6463. */
  6464. getOffset(): number;
  6465. /**
  6466. * Returns the number of components per vertex attribute (integer)
  6467. * @returns the size in float
  6468. */
  6469. getSize(): number;
  6470. /**
  6471. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6472. * @returns true if this buffer is instanced
  6473. */
  6474. getIsInstanced(): boolean;
  6475. /**
  6476. * Returns the instancing divisor, zero for non-instanced (integer).
  6477. * @returns a number
  6478. */
  6479. getInstanceDivisor(): number;
  6480. /**
  6481. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6482. * @param data defines the data to store
  6483. */
  6484. create(data?: DataArray): void;
  6485. /**
  6486. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6487. * This function will create a new buffer if the current one is not updatable
  6488. * @param data defines the data to store
  6489. */
  6490. update(data: DataArray): void;
  6491. /**
  6492. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6493. * Returns the directly updated WebGLBuffer.
  6494. * @param data the new data
  6495. * @param offset the new offset
  6496. * @param useBytes set to true if the offset is in bytes
  6497. */
  6498. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6499. /**
  6500. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6501. */
  6502. dispose(): void;
  6503. /**
  6504. * Enumerates each value of this vertex buffer as numbers.
  6505. * @param count the number of values to enumerate
  6506. * @param callback the callback function called for each value
  6507. */
  6508. forEach(count: number, callback: (value: number, index: number) => void): void;
  6509. /**
  6510. * Positions
  6511. */
  6512. static readonly PositionKind: string;
  6513. /**
  6514. * Normals
  6515. */
  6516. static readonly NormalKind: string;
  6517. /**
  6518. * Tangents
  6519. */
  6520. static readonly TangentKind: string;
  6521. /**
  6522. * Texture coordinates
  6523. */
  6524. static readonly UVKind: string;
  6525. /**
  6526. * Texture coordinates 2
  6527. */
  6528. static readonly UV2Kind: string;
  6529. /**
  6530. * Texture coordinates 3
  6531. */
  6532. static readonly UV3Kind: string;
  6533. /**
  6534. * Texture coordinates 4
  6535. */
  6536. static readonly UV4Kind: string;
  6537. /**
  6538. * Texture coordinates 5
  6539. */
  6540. static readonly UV5Kind: string;
  6541. /**
  6542. * Texture coordinates 6
  6543. */
  6544. static readonly UV6Kind: string;
  6545. /**
  6546. * Colors
  6547. */
  6548. static readonly ColorKind: string;
  6549. /**
  6550. * Matrix indices (for bones)
  6551. */
  6552. static readonly MatricesIndicesKind: string;
  6553. /**
  6554. * Matrix weights (for bones)
  6555. */
  6556. static readonly MatricesWeightsKind: string;
  6557. /**
  6558. * Additional matrix indices (for bones)
  6559. */
  6560. static readonly MatricesIndicesExtraKind: string;
  6561. /**
  6562. * Additional matrix weights (for bones)
  6563. */
  6564. static readonly MatricesWeightsExtraKind: string;
  6565. /**
  6566. * Deduces the stride given a kind.
  6567. * @param kind The kind string to deduce
  6568. * @returns The deduced stride
  6569. */
  6570. static DeduceStride(kind: string): number;
  6571. /**
  6572. * Gets the byte length of the given type.
  6573. * @param type the type
  6574. * @returns the number of bytes
  6575. */
  6576. static GetTypeByteLength(type: number): number;
  6577. /**
  6578. * Enumerates each value of the given parameters as numbers.
  6579. * @param data the data to enumerate
  6580. * @param byteOffset the byte offset of the data
  6581. * @param byteStride the byte stride of the data
  6582. * @param componentCount the number of components per element
  6583. * @param componentType the type of the component
  6584. * @param count the number of values to enumerate
  6585. * @param normalized whether the data is normalized
  6586. * @param callback the callback function called for each value
  6587. */
  6588. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6589. private static _GetFloatValue;
  6590. }
  6591. }
  6592. declare module BABYLON {
  6593. /**
  6594. * @hidden
  6595. */
  6596. export class IntersectionInfo {
  6597. bu: Nullable<number>;
  6598. bv: Nullable<number>;
  6599. distance: number;
  6600. faceId: number;
  6601. subMeshId: number;
  6602. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6603. }
  6604. }
  6605. declare module BABYLON {
  6606. /**
  6607. * Represens a plane by the equation ax + by + cz + d = 0
  6608. */
  6609. export class Plane {
  6610. private static _TmpMatrix;
  6611. /**
  6612. * Normal of the plane (a,b,c)
  6613. */
  6614. normal: Vector3;
  6615. /**
  6616. * d component of the plane
  6617. */
  6618. d: number;
  6619. /**
  6620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6621. * @param a a component of the plane
  6622. * @param b b component of the plane
  6623. * @param c c component of the plane
  6624. * @param d d component of the plane
  6625. */
  6626. constructor(a: number, b: number, c: number, d: number);
  6627. /**
  6628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6629. */
  6630. asArray(): number[];
  6631. /**
  6632. * @returns a new plane copied from the current Plane.
  6633. */
  6634. clone(): Plane;
  6635. /**
  6636. * @returns the string "Plane".
  6637. */
  6638. getClassName(): string;
  6639. /**
  6640. * @returns the Plane hash code.
  6641. */
  6642. getHashCode(): number;
  6643. /**
  6644. * Normalize the current Plane in place.
  6645. * @returns the updated Plane.
  6646. */
  6647. normalize(): Plane;
  6648. /**
  6649. * Applies a transformation the plane and returns the result
  6650. * @param transformation the transformation matrix to be applied to the plane
  6651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6652. */
  6653. transform(transformation: DeepImmutable<Matrix>): Plane;
  6654. /**
  6655. * Calcualtte the dot product between the point and the plane normal
  6656. * @param point point to calculate the dot product with
  6657. * @returns the dot product (float) of the point coordinates and the plane normal.
  6658. */
  6659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6660. /**
  6661. * Updates the current Plane from the plane defined by the three given points.
  6662. * @param point1 one of the points used to contruct the plane
  6663. * @param point2 one of the points used to contruct the plane
  6664. * @param point3 one of the points used to contruct the plane
  6665. * @returns the updated Plane.
  6666. */
  6667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Checks if the plane is facing a given direction
  6670. * @param direction the direction to check if the plane is facing
  6671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6672. * @returns True is the vector "direction" is the same side than the plane normal.
  6673. */
  6674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6675. /**
  6676. * Calculates the distance to a point
  6677. * @param point point to calculate distance to
  6678. * @returns the signed distance (float) from the given point to the Plane.
  6679. */
  6680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6681. /**
  6682. * Creates a plane from an array
  6683. * @param array the array to create a plane from
  6684. * @returns a new Plane from the given array.
  6685. */
  6686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6687. /**
  6688. * Creates a plane from three points
  6689. * @param point1 point used to create the plane
  6690. * @param point2 point used to create the plane
  6691. * @param point3 point used to create the plane
  6692. * @returns a new Plane defined by the three given points.
  6693. */
  6694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Creates a plane from an origin point and a normal
  6697. * @param origin origin of the plane to be constructed
  6698. * @param normal normal of the plane to be constructed
  6699. * @returns a new Plane the normal vector to this plane at the given origin point.
  6700. * Note : the vector "normal" is updated because normalized.
  6701. */
  6702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6703. /**
  6704. * Calculates the distance from a plane and a point
  6705. * @param origin origin of the plane to be constructed
  6706. * @param normal normal of the plane to be constructed
  6707. * @param point point to calculate distance to
  6708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6709. */
  6710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6711. }
  6712. }
  6713. declare module BABYLON {
  6714. /**
  6715. * Class used to store bounding sphere information
  6716. */
  6717. export class BoundingSphere {
  6718. /**
  6719. * Gets the center of the bounding sphere in local space
  6720. */
  6721. readonly center: Vector3;
  6722. /**
  6723. * Radius of the bounding sphere in local space
  6724. */
  6725. radius: number;
  6726. /**
  6727. * Gets the center of the bounding sphere in world space
  6728. */
  6729. readonly centerWorld: Vector3;
  6730. /**
  6731. * Radius of the bounding sphere in world space
  6732. */
  6733. radiusWorld: number;
  6734. /**
  6735. * Gets the minimum vector in local space
  6736. */
  6737. readonly minimum: Vector3;
  6738. /**
  6739. * Gets the maximum vector in local space
  6740. */
  6741. readonly maximum: Vector3;
  6742. private _worldMatrix;
  6743. private static readonly TmpVector3;
  6744. /**
  6745. * Creates a new bounding sphere
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding sphere by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingSphere;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding sphere is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding sphere center is in between the frustum planes.
  6779. * Used for optimistic fast inclusion.
  6780. * @param frustumPlanes defines the frustum planes to test
  6781. * @returns true if the sphere center is in between the frustum planes
  6782. */
  6783. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6784. /**
  6785. * Tests if a point is inside the bounding sphere
  6786. * @param point defines the point to test
  6787. * @returns true if the point is inside the bounding sphere
  6788. */
  6789. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6790. /**
  6791. * Checks if two sphere intersct
  6792. * @param sphere0 sphere 0
  6793. * @param sphere1 sphere 1
  6794. * @returns true if the speres intersect
  6795. */
  6796. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6797. }
  6798. }
  6799. declare module BABYLON {
  6800. /**
  6801. * Class used to store bounding box information
  6802. */
  6803. export class BoundingBox implements ICullable {
  6804. /**
  6805. * Gets the 8 vectors representing the bounding box in local space
  6806. */
  6807. readonly vectors: Vector3[];
  6808. /**
  6809. * Gets the center of the bounding box in local space
  6810. */
  6811. readonly center: Vector3;
  6812. /**
  6813. * Gets the center of the bounding box in world space
  6814. */
  6815. readonly centerWorld: Vector3;
  6816. /**
  6817. * Gets the extend size in local space
  6818. */
  6819. readonly extendSize: Vector3;
  6820. /**
  6821. * Gets the extend size in world space
  6822. */
  6823. readonly extendSizeWorld: Vector3;
  6824. /**
  6825. * Gets the OBB (object bounding box) directions
  6826. */
  6827. readonly directions: Vector3[];
  6828. /**
  6829. * Gets the 8 vectors representing the bounding box in world space
  6830. */
  6831. readonly vectorsWorld: Vector3[];
  6832. /**
  6833. * Gets the minimum vector in world space
  6834. */
  6835. readonly minimumWorld: Vector3;
  6836. /**
  6837. * Gets the maximum vector in world space
  6838. */
  6839. readonly maximumWorld: Vector3;
  6840. /**
  6841. * Gets the minimum vector in local space
  6842. */
  6843. readonly minimum: Vector3;
  6844. /**
  6845. * Gets the maximum vector in local space
  6846. */
  6847. readonly maximum: Vector3;
  6848. private _worldMatrix;
  6849. private static readonly TmpVector3;
  6850. /**
  6851. * @hidden
  6852. */
  6853. _tag: number;
  6854. /**
  6855. * Creates a new bounding box
  6856. * @param min defines the minimum vector (in local space)
  6857. * @param max defines the maximum vector (in local space)
  6858. * @param worldMatrix defines the new world matrix
  6859. */
  6860. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6861. /**
  6862. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6863. * @param min defines the new minimum vector (in local space)
  6864. * @param max defines the new maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6868. /**
  6869. * Scale the current bounding box by applying a scale factor
  6870. * @param factor defines the scale factor to apply
  6871. * @returns the current bounding box
  6872. */
  6873. scale(factor: number): BoundingBox;
  6874. /**
  6875. * Gets the world matrix of the bounding box
  6876. * @returns a matrix
  6877. */
  6878. getWorldMatrix(): DeepImmutable<Matrix>;
  6879. /** @hidden */
  6880. _update(world: DeepImmutable<Matrix>): void;
  6881. /**
  6882. * Tests if the bounding box is intersecting the frustum planes
  6883. * @param frustumPlanes defines the frustum planes to test
  6884. * @returns true if there is an intersection
  6885. */
  6886. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6887. /**
  6888. * Tests if the bounding box is entirely inside the frustum planes
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if there is an inclusion
  6891. */
  6892. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding box
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding box
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Tests if the bounding box intersects with a bounding sphere
  6901. * @param sphere defines the sphere to test
  6902. * @returns true if there is an intersection
  6903. */
  6904. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6905. /**
  6906. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6907. * @param min defines the min vector to use
  6908. * @param max defines the max vector to use
  6909. * @returns true if there is an intersection
  6910. */
  6911. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6912. /**
  6913. * Tests if two bounding boxes are intersections
  6914. * @param box0 defines the first box to test
  6915. * @param box1 defines the second box to test
  6916. * @returns true if there is an intersection
  6917. */
  6918. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6919. /**
  6920. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6921. * @param minPoint defines the minimum vector of the bounding box
  6922. * @param maxPoint defines the maximum vector of the bounding box
  6923. * @param sphereCenter defines the sphere center
  6924. * @param sphereRadius defines the sphere radius
  6925. * @returns true if there is an intersection
  6926. */
  6927. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6928. /**
  6929. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6930. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6931. * @param frustumPlanes defines the frustum planes to test
  6932. * @return true if there is an inclusion
  6933. */
  6934. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6935. /**
  6936. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @return true if there is an intersection
  6940. */
  6941. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. }
  6943. }
  6944. declare module BABYLON {
  6945. /** @hidden */
  6946. export class Collider {
  6947. /** Define if a collision was found */
  6948. collisionFound: boolean;
  6949. /**
  6950. * Define last intersection point in local space
  6951. */
  6952. intersectionPoint: Vector3;
  6953. /**
  6954. * Define last collided mesh
  6955. */
  6956. collidedMesh: Nullable<AbstractMesh>;
  6957. private _collisionPoint;
  6958. private _planeIntersectionPoint;
  6959. private _tempVector;
  6960. private _tempVector2;
  6961. private _tempVector3;
  6962. private _tempVector4;
  6963. private _edge;
  6964. private _baseToVertex;
  6965. private _destinationPoint;
  6966. private _slidePlaneNormal;
  6967. private _displacementVector;
  6968. /** @hidden */
  6969. _radius: Vector3;
  6970. /** @hidden */
  6971. _retry: number;
  6972. private _velocity;
  6973. private _basePoint;
  6974. private _epsilon;
  6975. /** @hidden */
  6976. _velocityWorldLength: number;
  6977. /** @hidden */
  6978. _basePointWorld: Vector3;
  6979. private _velocityWorld;
  6980. private _normalizedVelocity;
  6981. /** @hidden */
  6982. _initialVelocity: Vector3;
  6983. /** @hidden */
  6984. _initialPosition: Vector3;
  6985. private _nearestDistance;
  6986. private _collisionMask;
  6987. get collisionMask(): number;
  6988. set collisionMask(mask: number);
  6989. /**
  6990. * Gets the plane normal used to compute the sliding response (in local space)
  6991. */
  6992. get slidePlaneNormal(): Vector3;
  6993. /** @hidden */
  6994. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6995. /** @hidden */
  6996. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6997. /** @hidden */
  6998. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6999. /** @hidden */
  7000. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7001. /** @hidden */
  7002. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _getResponse(pos: Vector3, vel: Vector3): void;
  7005. }
  7006. }
  7007. declare module BABYLON {
  7008. /**
  7009. * Interface for cullable objects
  7010. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7011. */
  7012. export interface ICullable {
  7013. /**
  7014. * Checks if the object or part of the object is in the frustum
  7015. * @param frustumPlanes Camera near/planes
  7016. * @returns true if the object is in frustum otherwise false
  7017. */
  7018. isInFrustum(frustumPlanes: Plane[]): boolean;
  7019. /**
  7020. * Checks if a cullable object (mesh...) is in the camera frustum
  7021. * Unlike isInFrustum this cheks the full bounding box
  7022. * @param frustumPlanes Camera near/planes
  7023. * @returns true if the object is in frustum otherwise false
  7024. */
  7025. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7026. }
  7027. /**
  7028. * Info for a bounding data of a mesh
  7029. */
  7030. export class BoundingInfo implements ICullable {
  7031. /**
  7032. * Bounding box for the mesh
  7033. */
  7034. readonly boundingBox: BoundingBox;
  7035. /**
  7036. * Bounding sphere for the mesh
  7037. */
  7038. readonly boundingSphere: BoundingSphere;
  7039. private _isLocked;
  7040. private static readonly TmpVector3;
  7041. /**
  7042. * Constructs bounding info
  7043. * @param minimum min vector of the bounding box/sphere
  7044. * @param maximum max vector of the bounding box/sphere
  7045. * @param worldMatrix defines the new world matrix
  7046. */
  7047. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7048. /**
  7049. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7050. * @param min defines the new minimum vector (in local space)
  7051. * @param max defines the new maximum vector (in local space)
  7052. * @param worldMatrix defines the new world matrix
  7053. */
  7054. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * min vector of the bounding box/sphere
  7057. */
  7058. get minimum(): Vector3;
  7059. /**
  7060. * max vector of the bounding box/sphere
  7061. */
  7062. get maximum(): Vector3;
  7063. /**
  7064. * If the info is locked and won't be updated to avoid perf overhead
  7065. */
  7066. get isLocked(): boolean;
  7067. set isLocked(value: boolean);
  7068. /**
  7069. * Updates the bounding sphere and box
  7070. * @param world world matrix to be used to update
  7071. */
  7072. update(world: DeepImmutable<Matrix>): void;
  7073. /**
  7074. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7075. * @param center New center of the bounding info
  7076. * @param extend New extend of the bounding info
  7077. * @returns the current bounding info
  7078. */
  7079. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7080. /**
  7081. * Scale the current bounding info by applying a scale factor
  7082. * @param factor defines the scale factor to apply
  7083. * @returns the current bounding info
  7084. */
  7085. scale(factor: number): BoundingInfo;
  7086. /**
  7087. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7088. * @param frustumPlanes defines the frustum to test
  7089. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7090. * @returns true if the bounding info is in the frustum planes
  7091. */
  7092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7093. /**
  7094. * Gets the world distance between the min and max points of the bounding box
  7095. */
  7096. get diagonalLength(): number;
  7097. /**
  7098. * Checks if a cullable object (mesh...) is in the camera frustum
  7099. * Unlike isInFrustum this cheks the full bounding box
  7100. * @param frustumPlanes Camera near/planes
  7101. * @returns true if the object is in frustum otherwise false
  7102. */
  7103. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. /** @hidden */
  7105. _checkCollision(collider: Collider): boolean;
  7106. /**
  7107. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7108. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7109. * @param point the point to check intersection with
  7110. * @returns if the point intersects
  7111. */
  7112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7113. /**
  7114. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param boundingInfo the bounding info to check intersection with
  7117. * @param precise if the intersection should be done using OBB
  7118. * @returns if the bounding info intersects
  7119. */
  7120. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7121. }
  7122. }
  7123. declare module BABYLON {
  7124. /**
  7125. * Extracts minimum and maximum values from a list of indexed positions
  7126. * @param positions defines the positions to use
  7127. * @param indices defines the indices to the positions
  7128. * @param indexStart defines the start index
  7129. * @param indexCount defines the end index
  7130. * @param bias defines bias value to add to the result
  7131. * @return minimum and maximum values
  7132. */
  7133. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7134. minimum: Vector3;
  7135. maximum: Vector3;
  7136. };
  7137. /**
  7138. * Extracts minimum and maximum values from a list of positions
  7139. * @param positions defines the positions to use
  7140. * @param start defines the start index in the positions array
  7141. * @param count defines the number of positions to handle
  7142. * @param bias defines bias value to add to the result
  7143. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7144. * @return minimum and maximum values
  7145. */
  7146. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7147. minimum: Vector3;
  7148. maximum: Vector3;
  7149. };
  7150. }
  7151. declare module BABYLON {
  7152. /** @hidden */
  7153. export class WebGLDataBuffer extends DataBuffer {
  7154. private _buffer;
  7155. constructor(resource: WebGLBuffer);
  7156. get underlyingResource(): any;
  7157. }
  7158. }
  7159. declare module BABYLON {
  7160. /** @hidden */
  7161. export class WebGLPipelineContext implements IPipelineContext {
  7162. engine: ThinEngine;
  7163. program: Nullable<WebGLProgram>;
  7164. context?: WebGLRenderingContext;
  7165. vertexShader?: WebGLShader;
  7166. fragmentShader?: WebGLShader;
  7167. isParallelCompiled: boolean;
  7168. onCompiled?: () => void;
  7169. transformFeedback?: WebGLTransformFeedback | null;
  7170. vertexCompilationError: Nullable<string>;
  7171. fragmentCompilationError: Nullable<string>;
  7172. programLinkError: Nullable<string>;
  7173. programValidationError: Nullable<string>;
  7174. get isAsync(): boolean;
  7175. get isReady(): boolean;
  7176. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7177. _getVertexShaderCode(): string | null;
  7178. _getFragmentShaderCode(): string | null;
  7179. }
  7180. }
  7181. declare module BABYLON {
  7182. interface ThinEngine {
  7183. /**
  7184. * Create an uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Create a dynamic uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param elements defines the content of the uniform buffer
  7194. * @returns the webGL uniform buffer
  7195. */
  7196. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7197. /**
  7198. * Update an existing uniform buffer
  7199. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7200. * @param uniformBuffer defines the target uniform buffer
  7201. * @param elements defines the content to update
  7202. * @param offset defines the offset in the uniform buffer where update should start
  7203. * @param count defines the size of the data to update
  7204. */
  7205. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7206. /**
  7207. * Bind an uniform buffer to the current webGL context
  7208. * @param buffer defines the buffer to bind
  7209. */
  7210. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7211. /**
  7212. * Bind a buffer to the current webGL context at a given location
  7213. * @param buffer defines the buffer to bind
  7214. * @param location defines the index where to bind the buffer
  7215. */
  7216. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7217. /**
  7218. * Bind a specific block at a given index in a specific shader program
  7219. * @param pipelineContext defines the pipeline context to use
  7220. * @param blockName defines the block name
  7221. * @param index defines the index where to bind the block
  7222. */
  7223. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7224. }
  7225. }
  7226. declare module BABYLON {
  7227. /**
  7228. * Uniform buffer objects.
  7229. *
  7230. * Handles blocks of uniform on the GPU.
  7231. *
  7232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7233. *
  7234. * For more information, please refer to :
  7235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7236. */
  7237. export class UniformBuffer {
  7238. private _engine;
  7239. private _buffer;
  7240. private _data;
  7241. private _bufferData;
  7242. private _dynamic?;
  7243. private _uniformLocations;
  7244. private _uniformSizes;
  7245. private _uniformLocationPointer;
  7246. private _needSync;
  7247. private _noUBO;
  7248. private _currentEffect;
  7249. /** @hidden */
  7250. _alreadyBound: boolean;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. get useUbo(): boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. get isSync(): boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module BABYLON {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module BABYLON {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module BABYLON {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. interface ThinEngine {
  7602. /**
  7603. * Creates a depth stencil cube texture.
  7604. * This is only available in WebGL 2.
  7605. * @param size The size of face edge in the cube texture.
  7606. * @param options The options defining the cube texture.
  7607. * @returns The cube texture
  7608. */
  7609. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7610. /**
  7611. * Creates a cube texture
  7612. * @param rootUrl defines the url where the files to load is located
  7613. * @param scene defines the current scene
  7614. * @param files defines the list of files to load (1 per face)
  7615. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7616. * @param onLoad defines an optional callback raised when the texture is loaded
  7617. * @param onError defines an optional callback raised if there is an issue to load the texture
  7618. * @param format defines the format of the data
  7619. * @param forcedExtension defines the extension to use to pick the right loader
  7620. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7621. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7622. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7623. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7624. * @returns the cube texture as an InternalTexture
  7625. */
  7626. 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;
  7627. /**
  7628. * Creates a cube texture
  7629. * @param rootUrl defines the url where the files to load is located
  7630. * @param scene defines the current scene
  7631. * @param files defines the list of files to load (1 per face)
  7632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7633. * @param onLoad defines an optional callback raised when the texture is loaded
  7634. * @param onError defines an optional callback raised if there is an issue to load the texture
  7635. * @param format defines the format of the data
  7636. * @param forcedExtension defines the extension to use to pick the right loader
  7637. * @returns the cube texture as an InternalTexture
  7638. */
  7639. 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;
  7640. /**
  7641. * Creates a cube texture
  7642. * @param rootUrl defines the url where the files to load is located
  7643. * @param scene defines the current scene
  7644. * @param files defines the list of files to load (1 per face)
  7645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7646. * @param onLoad defines an optional callback raised when the texture is loaded
  7647. * @param onError defines an optional callback raised if there is an issue to load the texture
  7648. * @param format defines the format of the data
  7649. * @param forcedExtension defines the extension to use to pick the right loader
  7650. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7653. * @returns the cube texture as an InternalTexture
  7654. */
  7655. 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;
  7656. /** @hidden */
  7657. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7658. /** @hidden */
  7659. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7660. /** @hidden */
  7661. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7662. /** @hidden */
  7663. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7664. /**
  7665. * @hidden
  7666. */
  7667. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class for creating a cube texture
  7673. */
  7674. export class CubeTexture extends BaseTexture {
  7675. private _delayedOnLoad;
  7676. /**
  7677. * Observable triggered once the texture has been loaded.
  7678. */
  7679. onLoadObservable: Observable<CubeTexture>;
  7680. /**
  7681. * The url of the texture
  7682. */
  7683. url: string;
  7684. /**
  7685. * Gets or sets the center of the bounding box associated with the cube texture.
  7686. * It must define where the camera used to render the texture was set
  7687. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7688. */
  7689. boundingBoxPosition: Vector3;
  7690. private _boundingBoxSize;
  7691. /**
  7692. * Gets or sets the size of the bounding box associated with the cube texture
  7693. * When defined, the cubemap will switch to local mode
  7694. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7695. * @example https://www.babylonjs-playground.com/#RNASML
  7696. */
  7697. set boundingBoxSize(value: Vector3);
  7698. /**
  7699. * Returns the bounding box size
  7700. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7701. */
  7702. get boundingBoxSize(): Vector3;
  7703. protected _rotationY: number;
  7704. /**
  7705. * Sets texture matrix rotation angle around Y axis in radians.
  7706. */
  7707. set rotationY(value: number);
  7708. /**
  7709. * Gets texture matrix rotation angle around Y axis radians.
  7710. */
  7711. get rotationY(): number;
  7712. /**
  7713. * Are mip maps generated for this texture or not.
  7714. */
  7715. get noMipmap(): boolean;
  7716. private _noMipmap;
  7717. private _files;
  7718. protected _forcedExtension: Nullable<string>;
  7719. private _extensions;
  7720. private _textureMatrix;
  7721. private _format;
  7722. private _createPolynomials;
  7723. /** @hidden */
  7724. _prefiltered: boolean;
  7725. /**
  7726. * Creates a cube texture from an array of image urls
  7727. * @param files defines an array of image urls
  7728. * @param scene defines the hosting scene
  7729. * @param noMipmap specifies if mip maps are not used
  7730. * @returns a cube texture
  7731. */
  7732. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7733. /**
  7734. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7735. * @param url defines the url of the prefiltered texture
  7736. * @param scene defines the scene the texture is attached to
  7737. * @param forcedExtension defines the extension of the file if different from the url
  7738. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7739. * @return the prefiltered texture
  7740. */
  7741. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7742. /**
  7743. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7744. * as prefiltered data.
  7745. * @param rootUrl defines the url of the texture or the root name of the six images
  7746. * @param scene defines the scene the texture is attached to
  7747. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7748. * @param noMipmap defines if mipmaps should be created or not
  7749. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7750. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7751. * @param onError defines a callback triggered in case of error during load
  7752. * @param format defines the internal format to use for the texture once loaded
  7753. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7754. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7758. * @return the cube texture
  7759. */
  7760. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7761. /**
  7762. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7763. */
  7764. get isPrefiltered(): boolean;
  7765. /**
  7766. * Get the current class name of the texture useful for serialization or dynamic coding.
  7767. * @returns "CubeTexture"
  7768. */
  7769. getClassName(): string;
  7770. /**
  7771. * Update the url (and optional buffer) of this texture if url was null during construction.
  7772. * @param url the url of the texture
  7773. * @param forcedExtension defines the extension to use
  7774. * @param onLoad callback called when the texture is loaded (defaults to null)
  7775. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7776. */
  7777. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7778. /**
  7779. * Delays loading of the cube texture
  7780. * @param forcedExtension defines the extension to use
  7781. */
  7782. delayLoad(forcedExtension?: string): void;
  7783. /**
  7784. * Returns the reflection texture matrix
  7785. * @returns the reflection texture matrix
  7786. */
  7787. getReflectionTextureMatrix(): Matrix;
  7788. /**
  7789. * Sets the reflection texture matrix
  7790. * @param value Reflection texture matrix
  7791. */
  7792. setReflectionTextureMatrix(value: Matrix): void;
  7793. /**
  7794. * Parses text to create a cube texture
  7795. * @param parsedTexture define the serialized text to read from
  7796. * @param scene defines the hosting scene
  7797. * @param rootUrl defines the root url of the cube texture
  7798. * @returns a cube texture
  7799. */
  7800. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7801. /**
  7802. * Makes a clone, or deep copy, of the cube texture
  7803. * @returns a new cube texture
  7804. */
  7805. clone(): CubeTexture;
  7806. }
  7807. }
  7808. declare module BABYLON {
  7809. /**
  7810. * Manages the defines for the Material
  7811. */
  7812. export class MaterialDefines {
  7813. /** @hidden */
  7814. protected _keys: string[];
  7815. private _isDirty;
  7816. /** @hidden */
  7817. _renderId: number;
  7818. /** @hidden */
  7819. _areLightsDirty: boolean;
  7820. /** @hidden */
  7821. _areLightsDisposed: boolean;
  7822. /** @hidden */
  7823. _areAttributesDirty: boolean;
  7824. /** @hidden */
  7825. _areTexturesDirty: boolean;
  7826. /** @hidden */
  7827. _areFresnelDirty: boolean;
  7828. /** @hidden */
  7829. _areMiscDirty: boolean;
  7830. /** @hidden */
  7831. _areImageProcessingDirty: boolean;
  7832. /** @hidden */
  7833. _normals: boolean;
  7834. /** @hidden */
  7835. _uvs: boolean;
  7836. /** @hidden */
  7837. _needNormals: boolean;
  7838. /** @hidden */
  7839. _needUVs: boolean;
  7840. [id: string]: any;
  7841. /**
  7842. * Specifies if the material needs to be re-calculated
  7843. */
  7844. get isDirty(): boolean;
  7845. /**
  7846. * Marks the material to indicate that it has been re-calculated
  7847. */
  7848. markAsProcessed(): void;
  7849. /**
  7850. * Marks the material to indicate that it needs to be re-calculated
  7851. */
  7852. markAsUnprocessed(): void;
  7853. /**
  7854. * Marks the material to indicate all of its defines need to be re-calculated
  7855. */
  7856. markAllAsDirty(): void;
  7857. /**
  7858. * Marks the material to indicate that image processing needs to be re-calculated
  7859. */
  7860. markAsImageProcessingDirty(): void;
  7861. /**
  7862. * Marks the material to indicate the lights need to be re-calculated
  7863. * @param disposed Defines whether the light is dirty due to dispose or not
  7864. */
  7865. markAsLightDirty(disposed?: boolean): void;
  7866. /**
  7867. * Marks the attribute state as changed
  7868. */
  7869. markAsAttributesDirty(): void;
  7870. /**
  7871. * Marks the texture state as changed
  7872. */
  7873. markAsTexturesDirty(): void;
  7874. /**
  7875. * Marks the fresnel state as changed
  7876. */
  7877. markAsFresnelDirty(): void;
  7878. /**
  7879. * Marks the misc state as changed
  7880. */
  7881. markAsMiscDirty(): void;
  7882. /**
  7883. * Rebuilds the material defines
  7884. */
  7885. rebuild(): void;
  7886. /**
  7887. * Specifies if two material defines are equal
  7888. * @param other - A material define instance to compare to
  7889. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7890. */
  7891. isEqual(other: MaterialDefines): boolean;
  7892. /**
  7893. * Clones this instance's defines to another instance
  7894. * @param other - material defines to clone values to
  7895. */
  7896. cloneTo(other: MaterialDefines): void;
  7897. /**
  7898. * Resets the material define values
  7899. */
  7900. reset(): void;
  7901. /**
  7902. * Converts the material define values to a string
  7903. * @returns - String of material define information
  7904. */
  7905. toString(): string;
  7906. }
  7907. }
  7908. declare module BABYLON {
  7909. /**
  7910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7912. * 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;
  7913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7914. */
  7915. export class ColorCurves {
  7916. private _dirty;
  7917. private _tempColor;
  7918. private _globalCurve;
  7919. private _highlightsCurve;
  7920. private _midtonesCurve;
  7921. private _shadowsCurve;
  7922. private _positiveCurve;
  7923. private _negativeCurve;
  7924. private _globalHue;
  7925. private _globalDensity;
  7926. private _globalSaturation;
  7927. private _globalExposure;
  7928. /**
  7929. * Gets the global Hue value.
  7930. * 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).
  7931. */
  7932. get globalHue(): number;
  7933. /**
  7934. * Sets the global Hue value.
  7935. * 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).
  7936. */
  7937. set globalHue(value: number);
  7938. /**
  7939. * Gets the global Density value.
  7940. * 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.
  7941. * Values less than zero provide a filter of opposite hue.
  7942. */
  7943. get globalDensity(): number;
  7944. /**
  7945. * Sets the global Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. set globalDensity(value: number);
  7950. /**
  7951. * Gets the global Saturation value.
  7952. * 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.
  7953. */
  7954. get globalSaturation(): number;
  7955. /**
  7956. * Sets the global Saturation value.
  7957. * 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.
  7958. */
  7959. set globalSaturation(value: number);
  7960. /**
  7961. * Gets the global Exposure value.
  7962. * 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.
  7963. */
  7964. get globalExposure(): number;
  7965. /**
  7966. * Sets the global Exposure value.
  7967. * 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.
  7968. */
  7969. set globalExposure(value: number);
  7970. private _highlightsHue;
  7971. private _highlightsDensity;
  7972. private _highlightsSaturation;
  7973. private _highlightsExposure;
  7974. /**
  7975. * Gets the highlights Hue value.
  7976. * 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).
  7977. */
  7978. get highlightsHue(): number;
  7979. /**
  7980. * Sets the highlights Hue value.
  7981. * 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).
  7982. */
  7983. set highlightsHue(value: number);
  7984. /**
  7985. * Gets the highlights Density value.
  7986. * 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.
  7987. * Values less than zero provide a filter of opposite hue.
  7988. */
  7989. get highlightsDensity(): number;
  7990. /**
  7991. * Sets the highlights Density value.
  7992. * 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.
  7993. * Values less than zero provide a filter of opposite hue.
  7994. */
  7995. set highlightsDensity(value: number);
  7996. /**
  7997. * Gets the highlights Saturation value.
  7998. * 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.
  7999. */
  8000. get highlightsSaturation(): number;
  8001. /**
  8002. * Sets the highlights Saturation value.
  8003. * 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.
  8004. */
  8005. set highlightsSaturation(value: number);
  8006. /**
  8007. * Gets the highlights Exposure value.
  8008. * 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.
  8009. */
  8010. get highlightsExposure(): number;
  8011. /**
  8012. * Sets the highlights Exposure value.
  8013. * 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.
  8014. */
  8015. set highlightsExposure(value: number);
  8016. private _midtonesHue;
  8017. private _midtonesDensity;
  8018. private _midtonesSaturation;
  8019. private _midtonesExposure;
  8020. /**
  8021. * Gets the midtones Hue value.
  8022. * 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).
  8023. */
  8024. get midtonesHue(): number;
  8025. /**
  8026. * Sets the midtones Hue value.
  8027. * 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).
  8028. */
  8029. set midtonesHue(value: number);
  8030. /**
  8031. * Gets the midtones Density value.
  8032. * 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.
  8033. * Values less than zero provide a filter of opposite hue.
  8034. */
  8035. get midtonesDensity(): number;
  8036. /**
  8037. * Sets the midtones Density value.
  8038. * 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.
  8039. * Values less than zero provide a filter of opposite hue.
  8040. */
  8041. set midtonesDensity(value: number);
  8042. /**
  8043. * Gets the midtones Saturation value.
  8044. * 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.
  8045. */
  8046. get midtonesSaturation(): number;
  8047. /**
  8048. * Sets the midtones Saturation value.
  8049. * 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.
  8050. */
  8051. set midtonesSaturation(value: number);
  8052. /**
  8053. * Gets the midtones Exposure value.
  8054. * 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.
  8055. */
  8056. get midtonesExposure(): number;
  8057. /**
  8058. * Sets the midtones Exposure value.
  8059. * 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.
  8060. */
  8061. set midtonesExposure(value: number);
  8062. private _shadowsHue;
  8063. private _shadowsDensity;
  8064. private _shadowsSaturation;
  8065. private _shadowsExposure;
  8066. /**
  8067. * Gets the shadows Hue value.
  8068. * 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).
  8069. */
  8070. get shadowsHue(): number;
  8071. /**
  8072. * Sets the shadows Hue value.
  8073. * 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).
  8074. */
  8075. set shadowsHue(value: number);
  8076. /**
  8077. * Gets the shadows Density value.
  8078. * 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.
  8079. * Values less than zero provide a filter of opposite hue.
  8080. */
  8081. get shadowsDensity(): number;
  8082. /**
  8083. * Sets the shadows Density value.
  8084. * 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.
  8085. * Values less than zero provide a filter of opposite hue.
  8086. */
  8087. set shadowsDensity(value: number);
  8088. /**
  8089. * Gets the shadows Saturation value.
  8090. * 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.
  8091. */
  8092. get shadowsSaturation(): number;
  8093. /**
  8094. * Sets the shadows Saturation value.
  8095. * 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.
  8096. */
  8097. set shadowsSaturation(value: number);
  8098. /**
  8099. * Gets the shadows Exposure value.
  8100. * 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.
  8101. */
  8102. get shadowsExposure(): number;
  8103. /**
  8104. * Sets the shadows Exposure value.
  8105. * 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.
  8106. */
  8107. set shadowsExposure(value: number);
  8108. /**
  8109. * Returns the class name
  8110. * @returns The class name
  8111. */
  8112. getClassName(): string;
  8113. /**
  8114. * Binds the color curves to the shader.
  8115. * @param colorCurves The color curve to bind
  8116. * @param effect The effect to bind to
  8117. * @param positiveUniform The positive uniform shader parameter
  8118. * @param neutralUniform The neutral uniform shader parameter
  8119. * @param negativeUniform The negative uniform shader parameter
  8120. */
  8121. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8122. /**
  8123. * Prepare the list of uniforms associated with the ColorCurves effects.
  8124. * @param uniformsList The list of uniforms used in the effect
  8125. */
  8126. static PrepareUniforms(uniformsList: string[]): void;
  8127. /**
  8128. * Returns color grading data based on a hue, density, saturation and exposure value.
  8129. * @param filterHue The hue of the color filter.
  8130. * @param filterDensity The density of the color filter.
  8131. * @param saturation The saturation.
  8132. * @param exposure The exposure.
  8133. * @param result The result data container.
  8134. */
  8135. private getColorGradingDataToRef;
  8136. /**
  8137. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8138. * @param value The input slider value in range [-100,100].
  8139. * @returns Adjusted value.
  8140. */
  8141. private static applyColorGradingSliderNonlinear;
  8142. /**
  8143. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8144. * @param hue The hue (H) input.
  8145. * @param saturation The saturation (S) input.
  8146. * @param brightness The brightness (B) input.
  8147. * @result An RGBA color represented as Vector4.
  8148. */
  8149. private static fromHSBToRef;
  8150. /**
  8151. * Returns a value clamped between min and max
  8152. * @param value The value to clamp
  8153. * @param min The minimum of value
  8154. * @param max The maximum of value
  8155. * @returns The clamped value.
  8156. */
  8157. private static clamp;
  8158. /**
  8159. * Clones the current color curve instance.
  8160. * @return The cloned curves
  8161. */
  8162. clone(): ColorCurves;
  8163. /**
  8164. * Serializes the current color curve instance to a json representation.
  8165. * @return a JSON representation
  8166. */
  8167. serialize(): any;
  8168. /**
  8169. * Parses the color curve from a json representation.
  8170. * @param source the JSON source to parse
  8171. * @return The parsed curves
  8172. */
  8173. static Parse(source: any): ColorCurves;
  8174. }
  8175. }
  8176. declare module BABYLON {
  8177. /**
  8178. * Interface to follow in your material defines to integrate easily the
  8179. * Image proccessing functions.
  8180. * @hidden
  8181. */
  8182. export interface IImageProcessingConfigurationDefines {
  8183. IMAGEPROCESSING: boolean;
  8184. VIGNETTE: boolean;
  8185. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8186. VIGNETTEBLENDMODEOPAQUE: boolean;
  8187. TONEMAPPING: boolean;
  8188. TONEMAPPING_ACES: boolean;
  8189. CONTRAST: boolean;
  8190. EXPOSURE: boolean;
  8191. COLORCURVES: boolean;
  8192. COLORGRADING: boolean;
  8193. COLORGRADING3D: boolean;
  8194. SAMPLER3DGREENDEPTH: boolean;
  8195. SAMPLER3DBGRMAP: boolean;
  8196. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8197. }
  8198. /**
  8199. * @hidden
  8200. */
  8201. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8202. IMAGEPROCESSING: boolean;
  8203. VIGNETTE: boolean;
  8204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8205. VIGNETTEBLENDMODEOPAQUE: boolean;
  8206. TONEMAPPING: boolean;
  8207. TONEMAPPING_ACES: boolean;
  8208. CONTRAST: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. EXPOSURE: boolean;
  8216. constructor();
  8217. }
  8218. /**
  8219. * This groups together the common properties used for image processing either in direct forward pass
  8220. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8221. * or not.
  8222. */
  8223. export class ImageProcessingConfiguration {
  8224. /**
  8225. * Default tone mapping applied in BabylonJS.
  8226. */
  8227. static readonly TONEMAPPING_STANDARD: number;
  8228. /**
  8229. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8230. * to other engines rendering to increase portability.
  8231. */
  8232. static readonly TONEMAPPING_ACES: number;
  8233. /**
  8234. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8235. */
  8236. colorCurves: Nullable<ColorCurves>;
  8237. private _colorCurvesEnabled;
  8238. /**
  8239. * Gets wether the color curves effect is enabled.
  8240. */
  8241. get colorCurvesEnabled(): boolean;
  8242. /**
  8243. * Sets wether the color curves effect is enabled.
  8244. */
  8245. set colorCurvesEnabled(value: boolean);
  8246. private _colorGradingTexture;
  8247. /**
  8248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8249. */
  8250. get colorGradingTexture(): Nullable<BaseTexture>;
  8251. /**
  8252. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8253. */
  8254. set colorGradingTexture(value: Nullable<BaseTexture>);
  8255. private _colorGradingEnabled;
  8256. /**
  8257. * Gets wether the color grading effect is enabled.
  8258. */
  8259. get colorGradingEnabled(): boolean;
  8260. /**
  8261. * Sets wether the color grading effect is enabled.
  8262. */
  8263. set colorGradingEnabled(value: boolean);
  8264. private _colorGradingWithGreenDepth;
  8265. /**
  8266. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8267. */
  8268. get colorGradingWithGreenDepth(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8271. */
  8272. set colorGradingWithGreenDepth(value: boolean);
  8273. private _colorGradingBGR;
  8274. /**
  8275. * Gets wether the color grading texture contains BGR values.
  8276. */
  8277. get colorGradingBGR(): boolean;
  8278. /**
  8279. * Sets wether the color grading texture contains BGR values.
  8280. */
  8281. set colorGradingBGR(value: boolean);
  8282. /** @hidden */
  8283. _exposure: number;
  8284. /**
  8285. * Gets the Exposure used in the effect.
  8286. */
  8287. get exposure(): number;
  8288. /**
  8289. * Sets the Exposure used in the effect.
  8290. */
  8291. set exposure(value: number);
  8292. private _toneMappingEnabled;
  8293. /**
  8294. * Gets wether the tone mapping effect is enabled.
  8295. */
  8296. get toneMappingEnabled(): boolean;
  8297. /**
  8298. * Sets wether the tone mapping effect is enabled.
  8299. */
  8300. set toneMappingEnabled(value: boolean);
  8301. private _toneMappingType;
  8302. /**
  8303. * Gets the type of tone mapping effect.
  8304. */
  8305. get toneMappingType(): number;
  8306. /**
  8307. * Sets the type of tone mapping effect used in BabylonJS.
  8308. */
  8309. set toneMappingType(value: number);
  8310. protected _contrast: number;
  8311. /**
  8312. * Gets the contrast used in the effect.
  8313. */
  8314. get contrast(): number;
  8315. /**
  8316. * Sets the contrast used in the effect.
  8317. */
  8318. set contrast(value: number);
  8319. /**
  8320. * Vignette stretch size.
  8321. */
  8322. vignetteStretch: number;
  8323. /**
  8324. * Vignette centre X Offset.
  8325. */
  8326. vignetteCentreX: number;
  8327. /**
  8328. * Vignette centre Y Offset.
  8329. */
  8330. vignetteCentreY: number;
  8331. /**
  8332. * Vignette weight or intensity of the vignette effect.
  8333. */
  8334. vignetteWeight: number;
  8335. /**
  8336. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8337. * if vignetteEnabled is set to true.
  8338. */
  8339. vignetteColor: Color4;
  8340. /**
  8341. * Camera field of view used by the Vignette effect.
  8342. */
  8343. vignetteCameraFov: number;
  8344. private _vignetteBlendMode;
  8345. /**
  8346. * Gets the vignette blend mode allowing different kind of effect.
  8347. */
  8348. get vignetteBlendMode(): number;
  8349. /**
  8350. * Sets the vignette blend mode allowing different kind of effect.
  8351. */
  8352. set vignetteBlendMode(value: number);
  8353. private _vignetteEnabled;
  8354. /**
  8355. * Gets wether the vignette effect is enabled.
  8356. */
  8357. get vignetteEnabled(): boolean;
  8358. /**
  8359. * Sets wether the vignette effect is enabled.
  8360. */
  8361. set vignetteEnabled(value: boolean);
  8362. private _applyByPostProcess;
  8363. /**
  8364. * Gets wether the image processing is applied through a post process or not.
  8365. */
  8366. get applyByPostProcess(): boolean;
  8367. /**
  8368. * Sets wether the image processing is applied through a post process or not.
  8369. */
  8370. set applyByPostProcess(value: boolean);
  8371. private _isEnabled;
  8372. /**
  8373. * Gets wether the image processing is enabled or not.
  8374. */
  8375. get isEnabled(): boolean;
  8376. /**
  8377. * Sets wether the image processing is enabled or not.
  8378. */
  8379. set isEnabled(value: boolean);
  8380. /**
  8381. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8382. */
  8383. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8384. /**
  8385. * Method called each time the image processing information changes requires to recompile the effect.
  8386. */
  8387. protected _updateParameters(): void;
  8388. /**
  8389. * Gets the current class name.
  8390. * @return "ImageProcessingConfiguration"
  8391. */
  8392. getClassName(): string;
  8393. /**
  8394. * Prepare the list of uniforms associated with the Image Processing effects.
  8395. * @param uniforms The list of uniforms used in the effect
  8396. * @param defines the list of defines currently in use
  8397. */
  8398. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8399. /**
  8400. * Prepare the list of samplers associated with the Image Processing effects.
  8401. * @param samplersList The list of uniforms used in the effect
  8402. * @param defines the list of defines currently in use
  8403. */
  8404. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8405. /**
  8406. * Prepare the list of defines associated to the shader.
  8407. * @param defines the list of defines to complete
  8408. * @param forPostProcess Define if we are currently in post process mode or not
  8409. */
  8410. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8411. /**
  8412. * Returns true if all the image processing information are ready.
  8413. * @returns True if ready, otherwise, false
  8414. */
  8415. isReady(): boolean;
  8416. /**
  8417. * Binds the image processing to the shader.
  8418. * @param effect The effect to bind to
  8419. * @param overrideAspectRatio Override the aspect ratio of the effect
  8420. */
  8421. bind(effect: Effect, overrideAspectRatio?: number): void;
  8422. /**
  8423. * Clones the current image processing instance.
  8424. * @return The cloned image processing
  8425. */
  8426. clone(): ImageProcessingConfiguration;
  8427. /**
  8428. * Serializes the current image processing instance to a json representation.
  8429. * @return a JSON representation
  8430. */
  8431. serialize(): any;
  8432. /**
  8433. * Parses the image processing from a json representation.
  8434. * @param source the JSON source to parse
  8435. * @return The parsed image processing
  8436. */
  8437. static Parse(source: any): ImageProcessingConfiguration;
  8438. private static _VIGNETTEMODE_MULTIPLY;
  8439. private static _VIGNETTEMODE_OPAQUE;
  8440. /**
  8441. * Used to apply the vignette as a mix with the pixel color.
  8442. */
  8443. static get VIGNETTEMODE_MULTIPLY(): number;
  8444. /**
  8445. * Used to apply the vignette as a replacement of the pixel color.
  8446. */
  8447. static get VIGNETTEMODE_OPAQUE(): number;
  8448. }
  8449. }
  8450. declare module BABYLON {
  8451. /** @hidden */
  8452. export var postprocessVertexShader: {
  8453. name: string;
  8454. shader: string;
  8455. };
  8456. }
  8457. declare module BABYLON {
  8458. interface ThinEngine {
  8459. /**
  8460. * Creates a new render target texture
  8461. * @param size defines the size of the texture
  8462. * @param options defines the options used to create the texture
  8463. * @returns a new render target texture stored in an InternalTexture
  8464. */
  8465. createRenderTargetTexture(size: number | {
  8466. width: number;
  8467. height: number;
  8468. layers?: number;
  8469. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8470. /**
  8471. * Creates a depth stencil texture.
  8472. * This is only available in WebGL 2 or with the depth texture extension available.
  8473. * @param size The size of face edge in the texture.
  8474. * @param options The options defining the texture.
  8475. * @returns The texture
  8476. */
  8477. createDepthStencilTexture(size: number | {
  8478. width: number;
  8479. height: number;
  8480. layers?: number;
  8481. }, options: DepthTextureCreationOptions): InternalTexture;
  8482. /** @hidden */
  8483. _createDepthStencilTexture(size: number | {
  8484. width: number;
  8485. height: number;
  8486. layers?: number;
  8487. }, options: DepthTextureCreationOptions): InternalTexture;
  8488. }
  8489. }
  8490. declare module BABYLON {
  8491. /** Defines supported spaces */
  8492. export enum Space {
  8493. /** Local (object) space */
  8494. LOCAL = 0,
  8495. /** World space */
  8496. WORLD = 1,
  8497. /** Bone space */
  8498. BONE = 2
  8499. }
  8500. /** Defines the 3 main axes */
  8501. export class Axis {
  8502. /** X axis */
  8503. static X: Vector3;
  8504. /** Y axis */
  8505. static Y: Vector3;
  8506. /** Z axis */
  8507. static Z: Vector3;
  8508. }
  8509. }
  8510. declare module BABYLON {
  8511. /**
  8512. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8513. * This is the base of the follow, arc rotate cameras and Free camera
  8514. * @see http://doc.babylonjs.com/features/cameras
  8515. */
  8516. export class TargetCamera extends Camera {
  8517. private static _RigCamTransformMatrix;
  8518. private static _TargetTransformMatrix;
  8519. private static _TargetFocalPoint;
  8520. /**
  8521. * Define the current direction the camera is moving to
  8522. */
  8523. cameraDirection: Vector3;
  8524. /**
  8525. * Define the current rotation the camera is rotating to
  8526. */
  8527. cameraRotation: Vector2;
  8528. /**
  8529. * When set, the up vector of the camera will be updated by the rotation of the camera
  8530. */
  8531. updateUpVectorFromRotation: boolean;
  8532. private _tmpQuaternion;
  8533. /**
  8534. * Define the current rotation of the camera
  8535. */
  8536. rotation: Vector3;
  8537. /**
  8538. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8539. */
  8540. rotationQuaternion: Quaternion;
  8541. /**
  8542. * Define the current speed of the camera
  8543. */
  8544. speed: number;
  8545. /**
  8546. * Add constraint to the camera to prevent it to move freely in all directions and
  8547. * around all axis.
  8548. */
  8549. noRotationConstraint: boolean;
  8550. /**
  8551. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8552. * panning
  8553. */
  8554. invertRotation: boolean;
  8555. /**
  8556. * Speed multiplier for inverse camera panning
  8557. */
  8558. inverseRotationSpeed: number;
  8559. /**
  8560. * Define the current target of the camera as an object or a position.
  8561. */
  8562. lockedTarget: any;
  8563. /** @hidden */
  8564. _currentTarget: Vector3;
  8565. /** @hidden */
  8566. _initialFocalDistance: number;
  8567. /** @hidden */
  8568. _viewMatrix: Matrix;
  8569. /** @hidden */
  8570. _camMatrix: Matrix;
  8571. /** @hidden */
  8572. _cameraTransformMatrix: Matrix;
  8573. /** @hidden */
  8574. _cameraRotationMatrix: Matrix;
  8575. /** @hidden */
  8576. _referencePoint: Vector3;
  8577. /** @hidden */
  8578. _transformedReferencePoint: Vector3;
  8579. protected _globalCurrentTarget: Vector3;
  8580. protected _globalCurrentUpVector: Vector3;
  8581. /** @hidden */
  8582. _reset: () => void;
  8583. private _defaultUp;
  8584. /**
  8585. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8586. * This is the base of the follow, arc rotate cameras and Free camera
  8587. * @see http://doc.babylonjs.com/features/cameras
  8588. * @param name Defines the name of the camera in the scene
  8589. * @param position Defines the start position of the camera in the scene
  8590. * @param scene Defines the scene the camera belongs to
  8591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8592. */
  8593. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8594. /**
  8595. * Gets the position in front of the camera at a given distance.
  8596. * @param distance The distance from the camera we want the position to be
  8597. * @returns the position
  8598. */
  8599. getFrontPosition(distance: number): Vector3;
  8600. /** @hidden */
  8601. _getLockedTargetPosition(): Nullable<Vector3>;
  8602. private _storedPosition;
  8603. private _storedRotation;
  8604. private _storedRotationQuaternion;
  8605. /**
  8606. * Store current camera state of the camera (fov, position, rotation, etc..)
  8607. * @returns the camera
  8608. */
  8609. storeState(): Camera;
  8610. /**
  8611. * Restored camera state. You must call storeState() first
  8612. * @returns whether it was successful or not
  8613. * @hidden
  8614. */
  8615. _restoreStateValues(): boolean;
  8616. /** @hidden */
  8617. _initCache(): void;
  8618. /** @hidden */
  8619. _updateCache(ignoreParentClass?: boolean): void;
  8620. /** @hidden */
  8621. _isSynchronizedViewMatrix(): boolean;
  8622. /** @hidden */
  8623. _computeLocalCameraSpeed(): number;
  8624. /**
  8625. * Defines the target the camera should look at.
  8626. * @param target Defines the new target as a Vector or a mesh
  8627. */
  8628. setTarget(target: Vector3): void;
  8629. /**
  8630. * Return the current target position of the camera. This value is expressed in local space.
  8631. * @returns the target position
  8632. */
  8633. getTarget(): Vector3;
  8634. /** @hidden */
  8635. _decideIfNeedsToMove(): boolean;
  8636. /** @hidden */
  8637. _updatePosition(): void;
  8638. /** @hidden */
  8639. _checkInputs(): void;
  8640. protected _updateCameraRotationMatrix(): void;
  8641. /**
  8642. * 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)
  8643. * @returns the current camera
  8644. */
  8645. private _rotateUpVectorWithCameraRotationMatrix;
  8646. private _cachedRotationZ;
  8647. private _cachedQuaternionRotationZ;
  8648. /** @hidden */
  8649. _getViewMatrix(): Matrix;
  8650. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8651. /**
  8652. * @hidden
  8653. */
  8654. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8655. /**
  8656. * @hidden
  8657. */
  8658. _updateRigCameras(): void;
  8659. private _getRigCamPositionAndTarget;
  8660. /**
  8661. * Gets the current object class name.
  8662. * @return the class name
  8663. */
  8664. getClassName(): string;
  8665. }
  8666. }
  8667. declare module BABYLON {
  8668. /**
  8669. * Gather the list of keyboard event types as constants.
  8670. */
  8671. export class KeyboardEventTypes {
  8672. /**
  8673. * The keydown event is fired when a key becomes active (pressed).
  8674. */
  8675. static readonly KEYDOWN: number;
  8676. /**
  8677. * The keyup event is fired when a key has been released.
  8678. */
  8679. static readonly KEYUP: number;
  8680. }
  8681. /**
  8682. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8683. */
  8684. export class KeyboardInfo {
  8685. /**
  8686. * Defines the type of event (KeyboardEventTypes)
  8687. */
  8688. type: number;
  8689. /**
  8690. * Defines the related dom event
  8691. */
  8692. event: KeyboardEvent;
  8693. /**
  8694. * Instantiates a new keyboard info.
  8695. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8696. * @param type Defines the type of event (KeyboardEventTypes)
  8697. * @param event Defines the related dom event
  8698. */
  8699. constructor(
  8700. /**
  8701. * Defines the type of event (KeyboardEventTypes)
  8702. */
  8703. type: number,
  8704. /**
  8705. * Defines the related dom event
  8706. */
  8707. event: KeyboardEvent);
  8708. }
  8709. /**
  8710. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8711. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8712. */
  8713. export class KeyboardInfoPre extends KeyboardInfo {
  8714. /**
  8715. * Defines the type of event (KeyboardEventTypes)
  8716. */
  8717. type: number;
  8718. /**
  8719. * Defines the related dom event
  8720. */
  8721. event: KeyboardEvent;
  8722. /**
  8723. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8724. */
  8725. skipOnPointerObservable: boolean;
  8726. /**
  8727. * Instantiates a new keyboard pre info.
  8728. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8729. * @param type Defines the type of event (KeyboardEventTypes)
  8730. * @param event Defines the related dom event
  8731. */
  8732. constructor(
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number,
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent);
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Manage the keyboard inputs to control the movement of a free camera.
  8746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8747. */
  8748. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8749. /**
  8750. * Defines the camera the input is attached to.
  8751. */
  8752. camera: FreeCamera;
  8753. /**
  8754. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8755. */
  8756. keysUp: number[];
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8759. */
  8760. keysUpward: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8763. */
  8764. keysDown: number[];
  8765. /**
  8766. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8767. */
  8768. keysDownward: number[];
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8771. */
  8772. keysLeft: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8775. */
  8776. keysRight: number[];
  8777. private _keys;
  8778. private _onCanvasBlurObserver;
  8779. private _onKeyboardObserver;
  8780. private _engine;
  8781. private _scene;
  8782. /**
  8783. * Attach the input controls to a specific dom element to get the input from.
  8784. * @param element Defines the element the controls should be listened from
  8785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8786. */
  8787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8788. /**
  8789. * Detach the current controls from the specified dom element.
  8790. * @param element Defines the element to stop listening the inputs from
  8791. */
  8792. detachControl(element: Nullable<HTMLElement>): void;
  8793. /**
  8794. * Update the current camera state depending on the inputs that have been used this frame.
  8795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8796. */
  8797. checkInputs(): void;
  8798. /**
  8799. * Gets the class name of the current intput.
  8800. * @returns the class name
  8801. */
  8802. getClassName(): string;
  8803. /** @hidden */
  8804. _onLostFocus(): void;
  8805. /**
  8806. * Get the friendly name associated with the input class.
  8807. * @returns the input friendly name
  8808. */
  8809. getSimpleName(): string;
  8810. }
  8811. }
  8812. declare module BABYLON {
  8813. /**
  8814. * Interface describing all the common properties and methods a shadow light needs to implement.
  8815. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8816. * as well as binding the different shadow properties to the effects.
  8817. */
  8818. export interface IShadowLight extends Light {
  8819. /**
  8820. * The light id in the scene (used in scene.findLighById for instance)
  8821. */
  8822. id: string;
  8823. /**
  8824. * The position the shdow will be casted from.
  8825. */
  8826. position: Vector3;
  8827. /**
  8828. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8829. */
  8830. direction: Vector3;
  8831. /**
  8832. * The transformed position. Position of the light in world space taking parenting in account.
  8833. */
  8834. transformedPosition: Vector3;
  8835. /**
  8836. * The transformed direction. Direction of the light in world space taking parenting in account.
  8837. */
  8838. transformedDirection: Vector3;
  8839. /**
  8840. * The friendly name of the light in the scene.
  8841. */
  8842. name: string;
  8843. /**
  8844. * Defines the shadow projection clipping minimum z value.
  8845. */
  8846. shadowMinZ: number;
  8847. /**
  8848. * Defines the shadow projection clipping maximum z value.
  8849. */
  8850. shadowMaxZ: number;
  8851. /**
  8852. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8853. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8854. */
  8855. computeTransformedInformation(): boolean;
  8856. /**
  8857. * Gets the scene the light belongs to.
  8858. * @returns The scene
  8859. */
  8860. getScene(): Scene;
  8861. /**
  8862. * Callback defining a custom Projection Matrix Builder.
  8863. * This can be used to override the default projection matrix computation.
  8864. */
  8865. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8866. /**
  8867. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8868. * @param matrix The materix to updated with the projection information
  8869. * @param viewMatrix The transform matrix of the light
  8870. * @param renderList The list of mesh to render in the map
  8871. * @returns The current light
  8872. */
  8873. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8874. /**
  8875. * Gets the current depth scale used in ESM.
  8876. * @returns The scale
  8877. */
  8878. getDepthScale(): number;
  8879. /**
  8880. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8881. * @returns true if a cube texture needs to be use
  8882. */
  8883. needCube(): boolean;
  8884. /**
  8885. * Detects if the projection matrix requires to be recomputed this frame.
  8886. * @returns true if it requires to be recomputed otherwise, false.
  8887. */
  8888. needProjectionMatrixCompute(): boolean;
  8889. /**
  8890. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8891. */
  8892. forceProjectionMatrixCompute(): void;
  8893. /**
  8894. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8895. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8896. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8897. */
  8898. getShadowDirection(faceIndex?: number): Vector3;
  8899. /**
  8900. * Gets the minZ used for shadow according to both the scene and the light.
  8901. * @param activeCamera The camera we are returning the min for
  8902. * @returns the depth min z
  8903. */
  8904. getDepthMinZ(activeCamera: Camera): number;
  8905. /**
  8906. * Gets the maxZ used for shadow according to both the scene and the light.
  8907. * @param activeCamera The camera we are returning the max for
  8908. * @returns the depth max z
  8909. */
  8910. getDepthMaxZ(activeCamera: Camera): number;
  8911. }
  8912. /**
  8913. * Base implementation IShadowLight
  8914. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8915. */
  8916. export abstract class ShadowLight extends Light implements IShadowLight {
  8917. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8918. protected _position: Vector3;
  8919. protected _setPosition(value: Vector3): void;
  8920. /**
  8921. * Sets the position the shadow will be casted from. Also use as the light position for both
  8922. * point and spot lights.
  8923. */
  8924. get position(): Vector3;
  8925. /**
  8926. * Sets the position the shadow will be casted from. Also use as the light position for both
  8927. * point and spot lights.
  8928. */
  8929. set position(value: Vector3);
  8930. protected _direction: Vector3;
  8931. protected _setDirection(value: Vector3): void;
  8932. /**
  8933. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8934. * Also use as the light direction on spot and directional lights.
  8935. */
  8936. get direction(): Vector3;
  8937. /**
  8938. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8939. * Also use as the light direction on spot and directional lights.
  8940. */
  8941. set direction(value: Vector3);
  8942. protected _shadowMinZ: number;
  8943. /**
  8944. * Gets the shadow projection clipping minimum z value.
  8945. */
  8946. get shadowMinZ(): number;
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. set shadowMinZ(value: number);
  8951. protected _shadowMaxZ: number;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. get shadowMaxZ(): number;
  8956. /**
  8957. * Gets the shadow projection clipping maximum z value.
  8958. */
  8959. set shadowMaxZ(value: number);
  8960. /**
  8961. * Callback defining a custom Projection Matrix Builder.
  8962. * This can be used to override the default projection matrix computation.
  8963. */
  8964. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8965. /**
  8966. * The transformed position. Position of the light in world space taking parenting in account.
  8967. */
  8968. transformedPosition: Vector3;
  8969. /**
  8970. * The transformed direction. Direction of the light in world space taking parenting in account.
  8971. */
  8972. transformedDirection: Vector3;
  8973. private _needProjectionMatrixCompute;
  8974. /**
  8975. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8976. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8977. */
  8978. computeTransformedInformation(): boolean;
  8979. /**
  8980. * Return the depth scale used for the shadow map.
  8981. * @returns the depth scale.
  8982. */
  8983. getDepthScale(): number;
  8984. /**
  8985. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8986. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8987. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8988. */
  8989. getShadowDirection(faceIndex?: number): Vector3;
  8990. /**
  8991. * Returns the ShadowLight absolute position in the World.
  8992. * @returns the position vector in world space
  8993. */
  8994. getAbsolutePosition(): Vector3;
  8995. /**
  8996. * Sets the ShadowLight direction toward the passed target.
  8997. * @param target The point to target in local space
  8998. * @returns the updated ShadowLight direction
  8999. */
  9000. setDirectionToTarget(target: Vector3): Vector3;
  9001. /**
  9002. * Returns the light rotation in euler definition.
  9003. * @returns the x y z rotation in local space.
  9004. */
  9005. getRotation(): Vector3;
  9006. /**
  9007. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9008. * @returns true if a cube texture needs to be use
  9009. */
  9010. needCube(): boolean;
  9011. /**
  9012. * Detects if the projection matrix requires to be recomputed this frame.
  9013. * @returns true if it requires to be recomputed otherwise, false.
  9014. */
  9015. needProjectionMatrixCompute(): boolean;
  9016. /**
  9017. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9018. */
  9019. forceProjectionMatrixCompute(): void;
  9020. /** @hidden */
  9021. _initCache(): void;
  9022. /** @hidden */
  9023. _isSynchronized(): boolean;
  9024. /**
  9025. * Computes the world matrix of the node
  9026. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9027. * @returns the world matrix
  9028. */
  9029. computeWorldMatrix(force?: boolean): Matrix;
  9030. /**
  9031. * Gets the minZ used for shadow according to both the scene and the light.
  9032. * @param activeCamera The camera we are returning the min for
  9033. * @returns the depth min z
  9034. */
  9035. getDepthMinZ(activeCamera: Camera): number;
  9036. /**
  9037. * Gets the maxZ used for shadow according to both the scene and the light.
  9038. * @param activeCamera The camera we are returning the max for
  9039. * @returns the depth max z
  9040. */
  9041. getDepthMaxZ(activeCamera: Camera): number;
  9042. /**
  9043. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9044. * @param matrix The materix to updated with the projection information
  9045. * @param viewMatrix The transform matrix of the light
  9046. * @param renderList The list of mesh to render in the map
  9047. * @returns The current light
  9048. */
  9049. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9050. }
  9051. }
  9052. declare module BABYLON {
  9053. /**
  9054. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9055. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9056. */
  9057. export class EffectFallbacks implements IEffectFallbacks {
  9058. private _defines;
  9059. private _currentRank;
  9060. private _maxRank;
  9061. private _mesh;
  9062. /**
  9063. * Removes the fallback from the bound mesh.
  9064. */
  9065. unBindMesh(): void;
  9066. /**
  9067. * Adds a fallback on the specified property.
  9068. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9069. * @param define The name of the define in the shader
  9070. */
  9071. addFallback(rank: number, define: string): void;
  9072. /**
  9073. * Sets the mesh to use CPU skinning when needing to fallback.
  9074. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9075. * @param mesh The mesh to use the fallbacks.
  9076. */
  9077. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9078. /**
  9079. * Checks to see if more fallbacks are still availible.
  9080. */
  9081. get hasMoreFallbacks(): boolean;
  9082. /**
  9083. * Removes the defines that should be removed when falling back.
  9084. * @param currentDefines defines the current define statements for the shader.
  9085. * @param effect defines the current effect we try to compile
  9086. * @returns The resulting defines with defines of the current rank removed.
  9087. */
  9088. reduce(currentDefines: string, effect: Effect): string;
  9089. }
  9090. }
  9091. declare module BABYLON {
  9092. /**
  9093. * "Static Class" containing the most commonly used helper while dealing with material for
  9094. * rendering purpose.
  9095. *
  9096. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9097. *
  9098. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9099. */
  9100. export class MaterialHelper {
  9101. /**
  9102. * Bind the current view position to an effect.
  9103. * @param effect The effect to be bound
  9104. * @param scene The scene the eyes position is used from
  9105. */
  9106. static BindEyePosition(effect: Effect, scene: Scene): void;
  9107. /**
  9108. * Helps preparing the defines values about the UVs in used in the effect.
  9109. * UVs are shared as much as we can accross channels in the shaders.
  9110. * @param texture The texture we are preparing the UVs for
  9111. * @param defines The defines to update
  9112. * @param key The channel key "diffuse", "specular"... used in the shader
  9113. */
  9114. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9115. /**
  9116. * Binds a texture matrix value to its corrsponding uniform
  9117. * @param texture The texture to bind the matrix for
  9118. * @param uniformBuffer The uniform buffer receivin the data
  9119. * @param key The channel key "diffuse", "specular"... used in the shader
  9120. */
  9121. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9122. /**
  9123. * Gets the current status of the fog (should it be enabled?)
  9124. * @param mesh defines the mesh to evaluate for fog support
  9125. * @param scene defines the hosting scene
  9126. * @returns true if fog must be enabled
  9127. */
  9128. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9129. /**
  9130. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9131. * @param mesh defines the current mesh
  9132. * @param scene defines the current scene
  9133. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9134. * @param pointsCloud defines if point cloud rendering has to be turned on
  9135. * @param fogEnabled defines if fog has to be turned on
  9136. * @param alphaTest defines if alpha testing has to be turned on
  9137. * @param defines defines the current list of defines
  9138. */
  9139. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9140. /**
  9141. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9142. * @param scene defines the current scene
  9143. * @param engine defines the current engine
  9144. * @param defines specifies the list of active defines
  9145. * @param useInstances defines if instances have to be turned on
  9146. * @param useClipPlane defines if clip plane have to be turned on
  9147. */
  9148. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9149. /**
  9150. * Prepares the defines for bones
  9151. * @param mesh The mesh containing the geometry data we will draw
  9152. * @param defines The defines to update
  9153. */
  9154. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9155. /**
  9156. * Prepares the defines for morph targets
  9157. * @param mesh The mesh containing the geometry data we will draw
  9158. * @param defines The defines to update
  9159. */
  9160. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9161. /**
  9162. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9166. * @param useBones Precise whether bones should be used or not (override mesh info)
  9167. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9168. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9169. * @returns false if defines are considered not dirty and have not been checked
  9170. */
  9171. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9172. /**
  9173. * Prepares the defines related to multiview
  9174. * @param scene The scene we are intending to draw
  9175. * @param defines The defines to update
  9176. */
  9177. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9178. /**
  9179. * Prepares the defines related to the light information passed in parameter
  9180. * @param scene The scene we are intending to draw
  9181. * @param mesh The mesh the effect is compiling for
  9182. * @param light The light the effect is compiling for
  9183. * @param lightIndex The index of the light
  9184. * @param defines The defines to update
  9185. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9186. * @param state Defines the current state regarding what is needed (normals, etc...)
  9187. */
  9188. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9189. needNormals: boolean;
  9190. needRebuild: boolean;
  9191. shadowEnabled: boolean;
  9192. specularEnabled: boolean;
  9193. lightmapMode: boolean;
  9194. }): void;
  9195. /**
  9196. * Prepares the defines related to the light information passed in parameter
  9197. * @param scene The scene we are intending to draw
  9198. * @param mesh The mesh the effect is compiling for
  9199. * @param defines The defines to update
  9200. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9201. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9202. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9203. * @returns true if normals will be required for the rest of the effect
  9204. */
  9205. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9206. /**
  9207. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9208. * @param lightIndex defines the light index
  9209. * @param uniformsList The uniform list
  9210. * @param samplersList The sampler list
  9211. * @param projectedLightTexture defines if projected texture must be used
  9212. * @param uniformBuffersList defines an optional list of uniform buffers
  9213. */
  9214. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect
  9217. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9218. * @param samplersList The sampler list
  9219. * @param defines The defines helping in the list generation
  9220. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9221. */
  9222. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9223. /**
  9224. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9225. * @param defines The defines to update while falling back
  9226. * @param fallbacks The authorized effect fallbacks
  9227. * @param maxSimultaneousLights The maximum number of lights allowed
  9228. * @param rank the current rank of the Effect
  9229. * @returns The newly affected rank
  9230. */
  9231. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9232. private static _TmpMorphInfluencers;
  9233. /**
  9234. * Prepares the list of attributes required for morph targets according to the effect defines.
  9235. * @param attribs The current list of supported attribs
  9236. * @param mesh The mesh to prepare the morph targets attributes for
  9237. * @param influencers The number of influencers
  9238. */
  9239. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9240. /**
  9241. * Prepares the list of attributes required for morph targets according to the effect defines.
  9242. * @param attribs The current list of supported attribs
  9243. * @param mesh The mesh to prepare the morph targets attributes for
  9244. * @param defines The current Defines of the effect
  9245. */
  9246. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9247. /**
  9248. * Prepares the list of attributes required for bones according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param mesh The mesh to prepare the bones attributes for
  9251. * @param defines The current Defines of the effect
  9252. * @param fallbacks The current efffect fallback strategy
  9253. */
  9254. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9255. /**
  9256. * Check and prepare the list of attributes required for instances according to the effect defines.
  9257. * @param attribs The current list of supported attribs
  9258. * @param defines The current MaterialDefines of the effect
  9259. */
  9260. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9261. /**
  9262. * Add the list of attributes required for instances to the attribs array.
  9263. * @param attribs The current list of supported attribs
  9264. */
  9265. static PushAttributesForInstances(attribs: string[]): void;
  9266. /**
  9267. * Binds the light information to the effect.
  9268. * @param light The light containing the generator
  9269. * @param effect The effect we are binding the data to
  9270. * @param lightIndex The light index in the effect used to render
  9271. */
  9272. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9273. /**
  9274. * Binds the lights information from the scene to the effect for the given mesh.
  9275. * @param light Light to bind
  9276. * @param lightIndex Light index
  9277. * @param scene The scene where the light belongs to
  9278. * @param effect The effect we are binding the data to
  9279. * @param useSpecular Defines if specular is supported
  9280. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9281. */
  9282. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9283. /**
  9284. * Binds the lights information from the scene to the effect for the given mesh.
  9285. * @param scene The scene the lights belongs to
  9286. * @param mesh The mesh we are binding the information to render
  9287. * @param effect The effect we are binding the data to
  9288. * @param defines The generated defines for the effect
  9289. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9290. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9291. */
  9292. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9293. private static _tempFogColor;
  9294. /**
  9295. * Binds the fog information from the scene to the effect for the given mesh.
  9296. * @param scene The scene the lights belongs to
  9297. * @param mesh The mesh we are binding the information to render
  9298. * @param effect The effect we are binding the data to
  9299. * @param linearSpace Defines if the fog effect is applied in linear space
  9300. */
  9301. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9302. /**
  9303. * Binds the bones information from the mesh to the effect.
  9304. * @param mesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9308. /**
  9309. * Binds the morph targets information from the mesh to the effect.
  9310. * @param abstractMesh The mesh we are binding the information to render
  9311. * @param effect The effect we are binding the data to
  9312. */
  9313. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9314. /**
  9315. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9316. * @param defines The generated defines used in the effect
  9317. * @param effect The effect we are binding the data to
  9318. * @param scene The scene we are willing to render with logarithmic scale for
  9319. */
  9320. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9321. /**
  9322. * Binds the clip plane information from the scene to the effect.
  9323. * @param scene The scene the clip plane information are extracted from
  9324. * @param effect The effect we are binding the data to
  9325. */
  9326. static BindClipPlane(effect: Effect, scene: Scene): void;
  9327. }
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var packingFunctions: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var clipPlaneFragmentDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var clipPlaneFragment: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var shadowMapPixelShader: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var bonesDeclaration: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var morphTargetsVertexGlobalDeclaration: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var morphTargetsVertexDeclaration: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var instancesDeclaration: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var helperFunctions: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var clipPlaneVertexDeclaration: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var morphTargetsVertex: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /** @hidden */
  9408. export var instancesVertex: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module BABYLON {
  9414. /** @hidden */
  9415. export var bonesVertex: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module BABYLON {
  9421. /** @hidden */
  9422. export var clipPlaneVertex: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module BABYLON {
  9428. /** @hidden */
  9429. export var shadowMapVertexShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module BABYLON {
  9435. /** @hidden */
  9436. export var depthBoxBlurPixelShader: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module BABYLON {
  9442. /**
  9443. * Class representing a ray with position and direction
  9444. */
  9445. export class Ray {
  9446. /** origin point */
  9447. origin: Vector3;
  9448. /** direction */
  9449. direction: Vector3;
  9450. /** length of the ray */
  9451. length: number;
  9452. private static readonly TmpVector3;
  9453. private _tmpRay;
  9454. /**
  9455. * Creates a new ray
  9456. * @param origin origin point
  9457. * @param direction direction
  9458. * @param length length of the ray
  9459. */
  9460. constructor(
  9461. /** origin point */
  9462. origin: Vector3,
  9463. /** direction */
  9464. direction: Vector3,
  9465. /** length of the ray */
  9466. length?: number);
  9467. /**
  9468. * Checks if the ray intersects a box
  9469. * @param minimum bound of the box
  9470. * @param maximum bound of the box
  9471. * @param intersectionTreshold extra extend to be added to the box in all direction
  9472. * @returns if the box was hit
  9473. */
  9474. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9475. /**
  9476. * Checks if the ray intersects a box
  9477. * @param box the bounding box to check
  9478. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9479. * @returns if the box was hit
  9480. */
  9481. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9482. /**
  9483. * If the ray hits a sphere
  9484. * @param sphere the bounding sphere to check
  9485. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9486. * @returns true if it hits the sphere
  9487. */
  9488. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9489. /**
  9490. * If the ray hits a triange
  9491. * @param vertex0 triangle vertex
  9492. * @param vertex1 triangle vertex
  9493. * @param vertex2 triangle vertex
  9494. * @returns intersection information if hit
  9495. */
  9496. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9497. /**
  9498. * Checks if ray intersects a plane
  9499. * @param plane the plane to check
  9500. * @returns the distance away it was hit
  9501. */
  9502. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9503. /**
  9504. * Calculate the intercept of a ray on a given axis
  9505. * @param axis to check 'x' | 'y' | 'z'
  9506. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9507. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9508. */
  9509. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9510. /**
  9511. * Checks if ray intersects a mesh
  9512. * @param mesh the mesh to check
  9513. * @param fastCheck if only the bounding box should checked
  9514. * @returns picking info of the intersecton
  9515. */
  9516. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9517. /**
  9518. * Checks if ray intersects a mesh
  9519. * @param meshes the meshes to check
  9520. * @param fastCheck if only the bounding box should checked
  9521. * @param results array to store result in
  9522. * @returns Array of picking infos
  9523. */
  9524. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9525. private _comparePickingInfo;
  9526. private static smallnum;
  9527. private static rayl;
  9528. /**
  9529. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9530. * @param sega the first point of the segment to test the intersection against
  9531. * @param segb the second point of the segment to test the intersection against
  9532. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9533. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9534. */
  9535. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9536. /**
  9537. * Update the ray from viewport position
  9538. * @param x position
  9539. * @param y y position
  9540. * @param viewportWidth viewport width
  9541. * @param viewportHeight viewport height
  9542. * @param world world matrix
  9543. * @param view view matrix
  9544. * @param projection projection matrix
  9545. * @returns this ray updated
  9546. */
  9547. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9548. /**
  9549. * Creates a ray with origin and direction of 0,0,0
  9550. * @returns the new ray
  9551. */
  9552. static Zero(): Ray;
  9553. /**
  9554. * Creates a new ray from screen space and viewport
  9555. * @param x position
  9556. * @param y y position
  9557. * @param viewportWidth viewport width
  9558. * @param viewportHeight viewport height
  9559. * @param world world matrix
  9560. * @param view view matrix
  9561. * @param projection projection matrix
  9562. * @returns new ray
  9563. */
  9564. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9565. /**
  9566. * 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
  9567. * transformed to the given world matrix.
  9568. * @param origin The origin point
  9569. * @param end The end point
  9570. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9571. * @returns the new ray
  9572. */
  9573. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9574. /**
  9575. * Transforms a ray by a matrix
  9576. * @param ray ray to transform
  9577. * @param matrix matrix to apply
  9578. * @returns the resulting new ray
  9579. */
  9580. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9581. /**
  9582. * Transforms a ray by a matrix
  9583. * @param ray ray to transform
  9584. * @param matrix matrix to apply
  9585. * @param result ray to store result in
  9586. */
  9587. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9588. /**
  9589. * Unproject a ray from screen space to object space
  9590. * @param sourceX defines the screen space x coordinate to use
  9591. * @param sourceY defines the screen space y coordinate to use
  9592. * @param viewportWidth defines the current width of the viewport
  9593. * @param viewportHeight defines the current height of the viewport
  9594. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9595. * @param view defines the view matrix to use
  9596. * @param projection defines the projection matrix to use
  9597. */
  9598. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9599. }
  9600. /**
  9601. * Type used to define predicate used to select faces when a mesh intersection is detected
  9602. */
  9603. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9604. interface Scene {
  9605. /** @hidden */
  9606. _tempPickingRay: Nullable<Ray>;
  9607. /** @hidden */
  9608. _cachedRayForTransform: Ray;
  9609. /** @hidden */
  9610. _pickWithRayInverseMatrix: Matrix;
  9611. /** @hidden */
  9612. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9613. /** @hidden */
  9614. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9615. }
  9616. }
  9617. declare module BABYLON {
  9618. /**
  9619. * Groups all the scene component constants in one place to ease maintenance.
  9620. * @hidden
  9621. */
  9622. export class SceneComponentConstants {
  9623. static readonly NAME_EFFECTLAYER: string;
  9624. static readonly NAME_LAYER: string;
  9625. static readonly NAME_LENSFLARESYSTEM: string;
  9626. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9627. static readonly NAME_PARTICLESYSTEM: string;
  9628. static readonly NAME_GAMEPAD: string;
  9629. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9630. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9631. static readonly NAME_DEPTHRENDERER: string;
  9632. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9633. static readonly NAME_SPRITE: string;
  9634. static readonly NAME_OUTLINERENDERER: string;
  9635. static readonly NAME_PROCEDURALTEXTURE: string;
  9636. static readonly NAME_SHADOWGENERATOR: string;
  9637. static readonly NAME_OCTREE: string;
  9638. static readonly NAME_PHYSICSENGINE: string;
  9639. static readonly NAME_AUDIO: string;
  9640. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9641. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9642. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9644. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9645. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9646. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9647. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9648. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9649. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9650. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9651. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9652. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9653. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9654. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9655. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9656. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9657. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9658. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9659. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9660. static readonly STEP_AFTERRENDER_AUDIO: number;
  9661. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9662. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9663. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9664. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9665. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9666. static readonly STEP_POINTERMOVE_SPRITE: number;
  9667. static readonly STEP_POINTERDOWN_SPRITE: number;
  9668. static readonly STEP_POINTERUP_SPRITE: number;
  9669. }
  9670. /**
  9671. * This represents a scene component.
  9672. *
  9673. * This is used to decouple the dependency the scene is having on the different workloads like
  9674. * layers, post processes...
  9675. */
  9676. export interface ISceneComponent {
  9677. /**
  9678. * The name of the component. Each component must have a unique name.
  9679. */
  9680. name: string;
  9681. /**
  9682. * The scene the component belongs to.
  9683. */
  9684. scene: Scene;
  9685. /**
  9686. * Register the component to one instance of a scene.
  9687. */
  9688. register(): void;
  9689. /**
  9690. * Rebuilds the elements related to this component in case of
  9691. * context lost for instance.
  9692. */
  9693. rebuild(): void;
  9694. /**
  9695. * Disposes the component and the associated ressources.
  9696. */
  9697. dispose(): void;
  9698. }
  9699. /**
  9700. * This represents a SERIALIZABLE scene component.
  9701. *
  9702. * This extends Scene Component to add Serialization methods on top.
  9703. */
  9704. export interface ISceneSerializableComponent extends ISceneComponent {
  9705. /**
  9706. * Adds all the elements from the container to the scene
  9707. * @param container the container holding the elements
  9708. */
  9709. addFromContainer(container: AbstractScene): void;
  9710. /**
  9711. * Removes all the elements in the container from the scene
  9712. * @param container contains the elements to remove
  9713. * @param dispose if the removed element should be disposed (default: false)
  9714. */
  9715. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9716. /**
  9717. * Serializes the component data to the specified json object
  9718. * @param serializationObject The object to serialize to
  9719. */
  9720. serialize(serializationObject: any): void;
  9721. }
  9722. /**
  9723. * Strong typing of a Mesh related stage step action
  9724. */
  9725. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9726. /**
  9727. * Strong typing of a Evaluate Sub Mesh related stage step action
  9728. */
  9729. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9730. /**
  9731. * Strong typing of a Active Mesh related stage step action
  9732. */
  9733. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9734. /**
  9735. * Strong typing of a Camera related stage step action
  9736. */
  9737. export type CameraStageAction = (camera: Camera) => void;
  9738. /**
  9739. * Strong typing of a Camera Frame buffer related stage step action
  9740. */
  9741. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9742. /**
  9743. * Strong typing of a Render Target related stage step action
  9744. */
  9745. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9746. /**
  9747. * Strong typing of a RenderingGroup related stage step action
  9748. */
  9749. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9750. /**
  9751. * Strong typing of a Mesh Render related stage step action
  9752. */
  9753. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9754. /**
  9755. * Strong typing of a simple stage step action
  9756. */
  9757. export type SimpleStageAction = () => void;
  9758. /**
  9759. * Strong typing of a render target action.
  9760. */
  9761. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9762. /**
  9763. * Strong typing of a pointer move action.
  9764. */
  9765. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9766. /**
  9767. * Strong typing of a pointer up/down action.
  9768. */
  9769. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9770. /**
  9771. * Representation of a stage in the scene (Basically a list of ordered steps)
  9772. * @hidden
  9773. */
  9774. export class Stage<T extends Function> extends Array<{
  9775. index: number;
  9776. component: ISceneComponent;
  9777. action: T;
  9778. }> {
  9779. /**
  9780. * Hide ctor from the rest of the world.
  9781. * @param items The items to add.
  9782. */
  9783. private constructor();
  9784. /**
  9785. * Creates a new Stage.
  9786. * @returns A new instance of a Stage
  9787. */
  9788. static Create<T extends Function>(): Stage<T>;
  9789. /**
  9790. * Registers a step in an ordered way in the targeted stage.
  9791. * @param index Defines the position to register the step in
  9792. * @param component Defines the component attached to the step
  9793. * @param action Defines the action to launch during the step
  9794. */
  9795. registerStep(index: number, component: ISceneComponent, action: T): void;
  9796. /**
  9797. * Clears all the steps from the stage.
  9798. */
  9799. clear(): void;
  9800. }
  9801. }
  9802. declare module BABYLON {
  9803. interface Scene {
  9804. /** @hidden */
  9805. _pointerOverSprite: Nullable<Sprite>;
  9806. /** @hidden */
  9807. _pickedDownSprite: Nullable<Sprite>;
  9808. /** @hidden */
  9809. _tempSpritePickingRay: Nullable<Ray>;
  9810. /**
  9811. * All of the sprite managers added to this scene
  9812. * @see http://doc.babylonjs.com/babylon101/sprites
  9813. */
  9814. spriteManagers: Array<ISpriteManager>;
  9815. /**
  9816. * An event triggered when sprites rendering is about to start
  9817. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9818. */
  9819. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9820. /**
  9821. * An event triggered when sprites rendering is done
  9822. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9823. */
  9824. onAfterSpritesRenderingObservable: Observable<Scene>;
  9825. /** @hidden */
  9826. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9827. /** Launch a ray to try to pick a sprite in the scene
  9828. * @param x position on screen
  9829. * @param y position on screen
  9830. * @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
  9831. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9832. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9833. * @returns a PickingInfo
  9834. */
  9835. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9836. /** Use the given ray to pick a sprite in the scene
  9837. * @param ray The ray (in world space) to use to pick meshes
  9838. * @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
  9839. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9840. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9841. * @returns a PickingInfo
  9842. */
  9843. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9844. /** @hidden */
  9845. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9846. /** Launch a ray to try to pick sprites in the scene
  9847. * @param x position on screen
  9848. * @param y position on screen
  9849. * @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
  9850. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9851. * @returns a PickingInfo array
  9852. */
  9853. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9854. /** Use the given ray to pick sprites in the scene
  9855. * @param ray The ray (in world space) to use to pick meshes
  9856. * @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
  9857. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9858. * @returns a PickingInfo array
  9859. */
  9860. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9861. /**
  9862. * Force the sprite under the pointer
  9863. * @param sprite defines the sprite to use
  9864. */
  9865. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9866. /**
  9867. * Gets the sprite under the pointer
  9868. * @returns a Sprite or null if no sprite is under the pointer
  9869. */
  9870. getPointerOverSprite(): Nullable<Sprite>;
  9871. }
  9872. /**
  9873. * Defines the sprite scene component responsible to manage sprites
  9874. * in a given scene.
  9875. */
  9876. export class SpriteSceneComponent implements ISceneComponent {
  9877. /**
  9878. * The component name helpfull to identify the component in the list of scene components.
  9879. */
  9880. readonly name: string;
  9881. /**
  9882. * The scene the component belongs to.
  9883. */
  9884. scene: Scene;
  9885. /** @hidden */
  9886. private _spritePredicate;
  9887. /**
  9888. * Creates a new instance of the component for the given scene
  9889. * @param scene Defines the scene to register the component in
  9890. */
  9891. constructor(scene: Scene);
  9892. /**
  9893. * Registers the component in a given scene
  9894. */
  9895. register(): void;
  9896. /**
  9897. * Rebuilds the elements related to this component in case of
  9898. * context lost for instance.
  9899. */
  9900. rebuild(): void;
  9901. /**
  9902. * Disposes the component and the associated ressources.
  9903. */
  9904. dispose(): void;
  9905. private _pickSpriteButKeepRay;
  9906. private _pointerMove;
  9907. private _pointerDown;
  9908. private _pointerUp;
  9909. }
  9910. }
  9911. declare module BABYLON {
  9912. /** @hidden */
  9913. export var fogFragmentDeclaration: {
  9914. name: string;
  9915. shader: string;
  9916. };
  9917. }
  9918. declare module BABYLON {
  9919. /** @hidden */
  9920. export var fogFragment: {
  9921. name: string;
  9922. shader: string;
  9923. };
  9924. }
  9925. declare module BABYLON {
  9926. /** @hidden */
  9927. export var spritesPixelShader: {
  9928. name: string;
  9929. shader: string;
  9930. };
  9931. }
  9932. declare module BABYLON {
  9933. /** @hidden */
  9934. export var fogVertexDeclaration: {
  9935. name: string;
  9936. shader: string;
  9937. };
  9938. }
  9939. declare module BABYLON {
  9940. /** @hidden */
  9941. export var spritesVertexShader: {
  9942. name: string;
  9943. shader: string;
  9944. };
  9945. }
  9946. declare module BABYLON {
  9947. /**
  9948. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9949. */
  9950. export interface ISpriteManager extends IDisposable {
  9951. /**
  9952. * Restricts the camera to viewing objects with the same layerMask.
  9953. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9954. */
  9955. layerMask: number;
  9956. /**
  9957. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9958. */
  9959. isPickable: boolean;
  9960. /**
  9961. * Specifies the rendering group id for this mesh (0 by default)
  9962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9963. */
  9964. renderingGroupId: number;
  9965. /**
  9966. * Defines the list of sprites managed by the manager.
  9967. */
  9968. sprites: Array<Sprite>;
  9969. /**
  9970. * Tests the intersection of a sprite with a specific ray.
  9971. * @param ray The ray we are sending to test the collision
  9972. * @param camera The camera space we are sending rays in
  9973. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9974. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9975. * @returns picking info or null.
  9976. */
  9977. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9978. /**
  9979. * Intersects the sprites with a ray
  9980. * @param ray defines the ray to intersect with
  9981. * @param camera defines the current active camera
  9982. * @param predicate defines a predicate used to select candidate sprites
  9983. * @returns null if no hit or a PickingInfo array
  9984. */
  9985. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9986. /**
  9987. * Renders the list of sprites on screen.
  9988. */
  9989. render(): void;
  9990. }
  9991. /**
  9992. * Class used to manage multiple sprites on the same spritesheet
  9993. * @see http://doc.babylonjs.com/babylon101/sprites
  9994. */
  9995. export class SpriteManager implements ISpriteManager {
  9996. /** defines the manager's name */
  9997. name: string;
  9998. /** Gets the list of sprites */
  9999. sprites: Sprite[];
  10000. /** Gets or sets the rendering group id (0 by default) */
  10001. renderingGroupId: number;
  10002. /** Gets or sets camera layer mask */
  10003. layerMask: number;
  10004. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10005. fogEnabled: boolean;
  10006. /** Gets or sets a boolean indicating if the sprites are pickable */
  10007. isPickable: boolean;
  10008. /** Defines the default width of a cell in the spritesheet */
  10009. cellWidth: number;
  10010. /** Defines the default height of a cell in the spritesheet */
  10011. cellHeight: number;
  10012. /** Associative array from JSON sprite data file */
  10013. private _cellData;
  10014. /** Array of sprite names from JSON sprite data file */
  10015. private _spriteMap;
  10016. /** True when packed cell data from JSON file is ready*/
  10017. private _packedAndReady;
  10018. /**
  10019. * An event triggered when the manager is disposed.
  10020. */
  10021. onDisposeObservable: Observable<SpriteManager>;
  10022. private _onDisposeObserver;
  10023. /**
  10024. * Callback called when the manager is disposed
  10025. */
  10026. set onDispose(callback: () => void);
  10027. private _capacity;
  10028. private _fromPacked;
  10029. private _spriteTexture;
  10030. private _epsilon;
  10031. private _scene;
  10032. private _vertexData;
  10033. private _buffer;
  10034. private _vertexBuffers;
  10035. private _indexBuffer;
  10036. private _effectBase;
  10037. private _effectFog;
  10038. /**
  10039. * Gets or sets the spritesheet texture
  10040. */
  10041. get texture(): Texture;
  10042. set texture(value: Texture);
  10043. private _blendMode;
  10044. /**
  10045. * Blend mode use to render the particle, it can be any of
  10046. * the static Constants.ALPHA_x properties provided in this class.
  10047. * Default value is Constants.ALPHA_COMBINE
  10048. */
  10049. get blendMode(): number;
  10050. set blendMode(blendMode: number);
  10051. /** Disables writing to the depth buffer when rendering the sprites.
  10052. * It can be handy to disable depth writing when using textures without alpha channel
  10053. * and setting some specific blend modes.
  10054. */
  10055. disableDepthWrite: boolean;
  10056. /**
  10057. * Creates a new sprite manager
  10058. * @param name defines the manager's name
  10059. * @param imgUrl defines the sprite sheet url
  10060. * @param capacity defines the maximum allowed number of sprites
  10061. * @param cellSize defines the size of a sprite cell
  10062. * @param scene defines the hosting scene
  10063. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10064. * @param samplingMode defines the smapling mode to use with spritesheet
  10065. * @param fromPacked set to false; do not alter
  10066. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10067. */
  10068. constructor(
  10069. /** defines the manager's name */
  10070. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10071. private _makePacked;
  10072. private _appendSpriteVertex;
  10073. /**
  10074. * Intersects the sprites with a ray
  10075. * @param ray defines the ray to intersect with
  10076. * @param camera defines the current active camera
  10077. * @param predicate defines a predicate used to select candidate sprites
  10078. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10079. * @returns null if no hit or a PickingInfo
  10080. */
  10081. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10082. /**
  10083. * Intersects the sprites with a ray
  10084. * @param ray defines the ray to intersect with
  10085. * @param camera defines the current active camera
  10086. * @param predicate defines a predicate used to select candidate sprites
  10087. * @returns null if no hit or a PickingInfo array
  10088. */
  10089. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10090. /**
  10091. * Render all child sprites
  10092. */
  10093. render(): void;
  10094. /**
  10095. * Release associated resources
  10096. */
  10097. dispose(): void;
  10098. }
  10099. }
  10100. declare module BABYLON {
  10101. /** Interface used by value gradients (color, factor, ...) */
  10102. export interface IValueGradient {
  10103. /**
  10104. * Gets or sets the gradient value (between 0 and 1)
  10105. */
  10106. gradient: number;
  10107. }
  10108. /** Class used to store color4 gradient */
  10109. export class ColorGradient implements IValueGradient {
  10110. /**
  10111. * Gets or sets the gradient value (between 0 and 1)
  10112. */
  10113. gradient: number;
  10114. /**
  10115. * Gets or sets first associated color
  10116. */
  10117. color1: Color4;
  10118. /**
  10119. * Gets or sets second associated color
  10120. */
  10121. color2?: Color4 | undefined;
  10122. /**
  10123. * Creates a new color4 gradient
  10124. * @param gradient gets or sets the gradient value (between 0 and 1)
  10125. * @param color1 gets or sets first associated color
  10126. * @param color2 gets or sets first second color
  10127. */
  10128. constructor(
  10129. /**
  10130. * Gets or sets the gradient value (between 0 and 1)
  10131. */
  10132. gradient: number,
  10133. /**
  10134. * Gets or sets first associated color
  10135. */
  10136. color1: Color4,
  10137. /**
  10138. * Gets or sets second associated color
  10139. */
  10140. color2?: Color4 | undefined);
  10141. /**
  10142. * Will get a color picked randomly between color1 and color2.
  10143. * If color2 is undefined then color1 will be used
  10144. * @param result defines the target Color4 to store the result in
  10145. */
  10146. getColorToRef(result: Color4): void;
  10147. }
  10148. /** Class used to store color 3 gradient */
  10149. export class Color3Gradient implements IValueGradient {
  10150. /**
  10151. * Gets or sets the gradient value (between 0 and 1)
  10152. */
  10153. gradient: number;
  10154. /**
  10155. * Gets or sets the associated color
  10156. */
  10157. color: Color3;
  10158. /**
  10159. * Creates a new color3 gradient
  10160. * @param gradient gets or sets the gradient value (between 0 and 1)
  10161. * @param color gets or sets associated color
  10162. */
  10163. constructor(
  10164. /**
  10165. * Gets or sets the gradient value (between 0 and 1)
  10166. */
  10167. gradient: number,
  10168. /**
  10169. * Gets or sets the associated color
  10170. */
  10171. color: Color3);
  10172. }
  10173. /** Class used to store factor gradient */
  10174. export class FactorGradient implements IValueGradient {
  10175. /**
  10176. * Gets or sets the gradient value (between 0 and 1)
  10177. */
  10178. gradient: number;
  10179. /**
  10180. * Gets or sets first associated factor
  10181. */
  10182. factor1: number;
  10183. /**
  10184. * Gets or sets second associated factor
  10185. */
  10186. factor2?: number | undefined;
  10187. /**
  10188. * Creates a new factor gradient
  10189. * @param gradient gets or sets the gradient value (between 0 and 1)
  10190. * @param factor1 gets or sets first associated factor
  10191. * @param factor2 gets or sets second associated factor
  10192. */
  10193. constructor(
  10194. /**
  10195. * Gets or sets the gradient value (between 0 and 1)
  10196. */
  10197. gradient: number,
  10198. /**
  10199. * Gets or sets first associated factor
  10200. */
  10201. factor1: number,
  10202. /**
  10203. * Gets or sets second associated factor
  10204. */
  10205. factor2?: number | undefined);
  10206. /**
  10207. * Will get a number picked randomly between factor1 and factor2.
  10208. * If factor2 is undefined then factor1 will be used
  10209. * @returns the picked number
  10210. */
  10211. getFactor(): number;
  10212. }
  10213. /**
  10214. * Helper used to simplify some generic gradient tasks
  10215. */
  10216. export class GradientHelper {
  10217. /**
  10218. * Gets the current gradient from an array of IValueGradient
  10219. * @param ratio defines the current ratio to get
  10220. * @param gradients defines the array of IValueGradient
  10221. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10222. */
  10223. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Interface for the size containing width and height
  10229. */
  10230. export interface ISize {
  10231. /**
  10232. * Width
  10233. */
  10234. width: number;
  10235. /**
  10236. * Heighht
  10237. */
  10238. height: number;
  10239. }
  10240. /**
  10241. * Size containing widht and height
  10242. */
  10243. export class Size implements ISize {
  10244. /**
  10245. * Width
  10246. */
  10247. width: number;
  10248. /**
  10249. * Height
  10250. */
  10251. height: number;
  10252. /**
  10253. * Creates a Size object from the given width and height (floats).
  10254. * @param width width of the new size
  10255. * @param height height of the new size
  10256. */
  10257. constructor(width: number, height: number);
  10258. /**
  10259. * Returns a string with the Size width and height
  10260. * @returns a string with the Size width and height
  10261. */
  10262. toString(): string;
  10263. /**
  10264. * "Size"
  10265. * @returns the string "Size"
  10266. */
  10267. getClassName(): string;
  10268. /**
  10269. * Returns the Size hash code.
  10270. * @returns a hash code for a unique width and height
  10271. */
  10272. getHashCode(): number;
  10273. /**
  10274. * Updates the current size from the given one.
  10275. * @param src the given size
  10276. */
  10277. copyFrom(src: Size): void;
  10278. /**
  10279. * Updates in place the current Size from the given floats.
  10280. * @param width width of the new size
  10281. * @param height height of the new size
  10282. * @returns the updated Size.
  10283. */
  10284. copyFromFloats(width: number, height: number): Size;
  10285. /**
  10286. * Updates in place the current Size from the given floats.
  10287. * @param width width to set
  10288. * @param height height to set
  10289. * @returns the updated Size.
  10290. */
  10291. set(width: number, height: number): Size;
  10292. /**
  10293. * Multiplies the width and height by numbers
  10294. * @param w factor to multiple the width by
  10295. * @param h factor to multiple the height by
  10296. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10297. */
  10298. multiplyByFloats(w: number, h: number): Size;
  10299. /**
  10300. * Clones the size
  10301. * @returns a new Size copied from the given one.
  10302. */
  10303. clone(): Size;
  10304. /**
  10305. * True if the current Size and the given one width and height are strictly equal.
  10306. * @param other the other size to compare against
  10307. * @returns True if the current Size and the given one width and height are strictly equal.
  10308. */
  10309. equals(other: Size): boolean;
  10310. /**
  10311. * The surface of the Size : width * height (float).
  10312. */
  10313. get surface(): number;
  10314. /**
  10315. * Create a new size of zero
  10316. * @returns a new Size set to (0.0, 0.0)
  10317. */
  10318. static Zero(): Size;
  10319. /**
  10320. * Sums the width and height of two sizes
  10321. * @param otherSize size to add to this size
  10322. * @returns a new Size set as the addition result of the current Size and the given one.
  10323. */
  10324. add(otherSize: Size): Size;
  10325. /**
  10326. * Subtracts the width and height of two
  10327. * @param otherSize size to subtract to this size
  10328. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10329. */
  10330. subtract(otherSize: Size): Size;
  10331. /**
  10332. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10333. * @param start starting size to lerp between
  10334. * @param end end size to lerp between
  10335. * @param amount amount to lerp between the start and end values
  10336. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10337. */
  10338. static Lerp(start: Size, end: Size, amount: number): Size;
  10339. }
  10340. }
  10341. declare module BABYLON {
  10342. interface ThinEngine {
  10343. /**
  10344. * Creates a dynamic texture
  10345. * @param width defines the width of the texture
  10346. * @param height defines the height of the texture
  10347. * @param generateMipMaps defines if the engine should generate the mip levels
  10348. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10349. * @returns the dynamic texture inside an InternalTexture
  10350. */
  10351. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10352. /**
  10353. * Update the content of a dynamic texture
  10354. * @param texture defines the texture to update
  10355. * @param canvas defines the canvas containing the source
  10356. * @param invertY defines if data must be stored with Y axis inverted
  10357. * @param premulAlpha defines if alpha is stored as premultiplied
  10358. * @param format defines the format of the data
  10359. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10360. */
  10361. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10362. }
  10363. }
  10364. declare module BABYLON {
  10365. /**
  10366. * Helper class used to generate a canvas to manipulate images
  10367. */
  10368. export class CanvasGenerator {
  10369. /**
  10370. * Create a new canvas (or offscreen canvas depending on the context)
  10371. * @param width defines the expected width
  10372. * @param height defines the expected height
  10373. * @return a new canvas or offscreen canvas
  10374. */
  10375. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10376. }
  10377. }
  10378. declare module BABYLON {
  10379. /**
  10380. * A class extending Texture allowing drawing on a texture
  10381. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10382. */
  10383. export class DynamicTexture extends Texture {
  10384. private _generateMipMaps;
  10385. private _canvas;
  10386. private _context;
  10387. private _engine;
  10388. /**
  10389. * Creates a DynamicTexture
  10390. * @param name defines the name of the texture
  10391. * @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
  10392. * @param scene defines the scene where you want the texture
  10393. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10394. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10395. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10396. */
  10397. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10398. /**
  10399. * Get the current class name of the texture useful for serialization or dynamic coding.
  10400. * @returns "DynamicTexture"
  10401. */
  10402. getClassName(): string;
  10403. /**
  10404. * Gets the current state of canRescale
  10405. */
  10406. get canRescale(): boolean;
  10407. private _recreate;
  10408. /**
  10409. * Scales the texture
  10410. * @param ratio the scale factor to apply to both width and height
  10411. */
  10412. scale(ratio: number): void;
  10413. /**
  10414. * Resizes the texture
  10415. * @param width the new width
  10416. * @param height the new height
  10417. */
  10418. scaleTo(width: number, height: number): void;
  10419. /**
  10420. * Gets the context of the canvas used by the texture
  10421. * @returns the canvas context of the dynamic texture
  10422. */
  10423. getContext(): CanvasRenderingContext2D;
  10424. /**
  10425. * Clears the texture
  10426. */
  10427. clear(): void;
  10428. /**
  10429. * Updates the texture
  10430. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10431. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10432. */
  10433. update(invertY?: boolean, premulAlpha?: boolean): void;
  10434. /**
  10435. * Draws text onto the texture
  10436. * @param text defines the text to be drawn
  10437. * @param x defines the placement of the text from the left
  10438. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10439. * @param font defines the font to be used with font-style, font-size, font-name
  10440. * @param color defines the color used for the text
  10441. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10443. * @param update defines whether texture is immediately update (default is true)
  10444. */
  10445. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10446. /**
  10447. * Clones the texture
  10448. * @returns the clone of the texture.
  10449. */
  10450. clone(): DynamicTexture;
  10451. /**
  10452. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10453. * @returns a serialized dynamic texture object
  10454. */
  10455. serialize(): any;
  10456. /** @hidden */
  10457. _rebuild(): void;
  10458. }
  10459. }
  10460. declare module BABYLON {
  10461. interface Engine {
  10462. /**
  10463. * Creates a raw texture
  10464. * @param data defines the data to store in the texture
  10465. * @param width defines the width of the texture
  10466. * @param height defines the height of the texture
  10467. * @param format defines the format of the data
  10468. * @param generateMipMaps defines if the engine should generate the mip levels
  10469. * @param invertY defines if data must be stored with Y axis inverted
  10470. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10471. * @param compression defines the compression used (null by default)
  10472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10473. * @returns the raw texture inside an InternalTexture
  10474. */
  10475. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10476. /**
  10477. * Update a raw texture
  10478. * @param texture defines the texture to update
  10479. * @param data defines the data to store in the texture
  10480. * @param format defines the format of the data
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. */
  10483. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10484. /**
  10485. * Update a raw texture
  10486. * @param texture defines the texture to update
  10487. * @param data defines the data to store in the texture
  10488. * @param format defines the format of the data
  10489. * @param invertY defines if data must be stored with Y axis inverted
  10490. * @param compression defines the compression used (null by default)
  10491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10492. */
  10493. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10494. /**
  10495. * Creates a new raw cube texture
  10496. * @param data defines the array of data to use to create each face
  10497. * @param size defines the size of the textures
  10498. * @param format defines the format of the data
  10499. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10500. * @param generateMipMaps defines if the engine should generate the mip levels
  10501. * @param invertY defines if data must be stored with Y axis inverted
  10502. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10503. * @param compression defines the compression used (null by default)
  10504. * @returns the cube texture as an InternalTexture
  10505. */
  10506. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10507. /**
  10508. * Update a raw cube texture
  10509. * @param texture defines the texture to udpdate
  10510. * @param data defines the data to store
  10511. * @param format defines the data format
  10512. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. */
  10515. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10516. /**
  10517. * Update a raw cube texture
  10518. * @param texture defines the texture to udpdate
  10519. * @param data defines the data to store
  10520. * @param format defines the data format
  10521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10522. * @param invertY defines if data must be stored with Y axis inverted
  10523. * @param compression defines the compression used (null by default)
  10524. */
  10525. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10526. /**
  10527. * Update a raw cube texture
  10528. * @param texture defines the texture to udpdate
  10529. * @param data defines the data to store
  10530. * @param format defines the data format
  10531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10532. * @param invertY defines if data must be stored with Y axis inverted
  10533. * @param compression defines the compression used (null by default)
  10534. * @param level defines which level of the texture to update
  10535. */
  10536. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10537. /**
  10538. * Creates a new raw cube texture from a specified url
  10539. * @param url defines the url where the data is located
  10540. * @param scene defines the current scene
  10541. * @param size defines the size of the textures
  10542. * @param format defines the format of the data
  10543. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10544. * @param noMipmap defines if the engine should avoid generating the mip levels
  10545. * @param callback defines a callback used to extract texture data from loaded data
  10546. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10547. * @param onLoad defines a callback called when texture is loaded
  10548. * @param onError defines a callback called if there is an error
  10549. * @returns the cube texture as an InternalTexture
  10550. */
  10551. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10552. /**
  10553. * Creates a new raw cube texture from a specified url
  10554. * @param url defines the url where the data is located
  10555. * @param scene defines the current scene
  10556. * @param size defines the size of the textures
  10557. * @param format defines the format of the data
  10558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10559. * @param noMipmap defines if the engine should avoid generating the mip levels
  10560. * @param callback defines a callback used to extract texture data from loaded data
  10561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10562. * @param onLoad defines a callback called when texture is loaded
  10563. * @param onError defines a callback called if there is an error
  10564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10565. * @param invertY defines if data must be stored with Y axis inverted
  10566. * @returns the cube texture as an InternalTexture
  10567. */
  10568. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10569. /**
  10570. * Creates a new raw 3D texture
  10571. * @param data defines the data used to create the texture
  10572. * @param width defines the width of the texture
  10573. * @param height defines the height of the texture
  10574. * @param depth defines the depth of the texture
  10575. * @param format defines the format of the texture
  10576. * @param generateMipMaps defines if the engine must generate mip levels
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10579. * @param compression defines the compressed used (can be null)
  10580. * @param textureType defines the compressed used (can be null)
  10581. * @returns a new raw 3D texture (stored in an InternalTexture)
  10582. */
  10583. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10584. /**
  10585. * Update a raw 3D texture
  10586. * @param texture defines the texture to update
  10587. * @param data defines the data to store
  10588. * @param format defines the data format
  10589. * @param invertY defines if data must be stored with Y axis inverted
  10590. */
  10591. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10592. /**
  10593. * Update a raw 3D texture
  10594. * @param texture defines the texture to update
  10595. * @param data defines the data to store
  10596. * @param format defines the data format
  10597. * @param invertY defines if data must be stored with Y axis inverted
  10598. * @param compression defines the used compression (can be null)
  10599. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10600. */
  10601. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10602. /**
  10603. * Creates a new raw 2D array texture
  10604. * @param data defines the data used to create the texture
  10605. * @param width defines the width of the texture
  10606. * @param height defines the height of the texture
  10607. * @param depth defines the number of layers of the texture
  10608. * @param format defines the format of the texture
  10609. * @param generateMipMaps defines if the engine must generate mip levels
  10610. * @param invertY defines if data must be stored with Y axis inverted
  10611. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10612. * @param compression defines the compressed used (can be null)
  10613. * @param textureType defines the compressed used (can be null)
  10614. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10615. */
  10616. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10617. /**
  10618. * Update a raw 2D array texture
  10619. * @param texture defines the texture to update
  10620. * @param data defines the data to store
  10621. * @param format defines the data format
  10622. * @param invertY defines if data must be stored with Y axis inverted
  10623. */
  10624. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10625. /**
  10626. * Update a raw 2D array texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store
  10629. * @param format defines the data format
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. * @param compression defines the used compression (can be null)
  10632. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10633. */
  10634. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10635. }
  10636. }
  10637. declare module BABYLON {
  10638. /**
  10639. * Raw texture can help creating a texture directly from an array of data.
  10640. * This can be super useful if you either get the data from an uncompressed source or
  10641. * if you wish to create your texture pixel by pixel.
  10642. */
  10643. export class RawTexture extends Texture {
  10644. /**
  10645. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10646. */
  10647. format: number;
  10648. private _engine;
  10649. /**
  10650. * Instantiates a new RawTexture.
  10651. * Raw texture can help creating a texture directly from an array of data.
  10652. * This can be super useful if you either get the data from an uncompressed source or
  10653. * if you wish to create your texture pixel by pixel.
  10654. * @param data define the array of data to use to create the texture
  10655. * @param width define the width of the texture
  10656. * @param height define the height of the texture
  10657. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10658. * @param scene define the scene the texture belongs to
  10659. * @param generateMipMaps define whether mip maps should be generated or not
  10660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10662. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10663. */
  10664. constructor(data: ArrayBufferView, width: number, height: number,
  10665. /**
  10666. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10667. */
  10668. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10669. /**
  10670. * Updates the texture underlying data.
  10671. * @param data Define the new data of the texture
  10672. */
  10673. update(data: ArrayBufferView): void;
  10674. /**
  10675. * Creates a luminance texture from some data.
  10676. * @param data Define the texture data
  10677. * @param width Define the width of the texture
  10678. * @param height Define the height of the texture
  10679. * @param scene Define the scene the texture belongs to
  10680. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10681. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10682. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10683. * @returns the luminance texture
  10684. */
  10685. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10686. /**
  10687. * Creates a luminance alpha texture from some data.
  10688. * @param data Define the texture data
  10689. * @param width Define the width of the texture
  10690. * @param height Define the height of the texture
  10691. * @param scene Define the scene the texture belongs to
  10692. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10693. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10694. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10695. * @returns the luminance alpha texture
  10696. */
  10697. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10698. /**
  10699. * Creates an alpha texture from some data.
  10700. * @param data Define the texture data
  10701. * @param width Define the width of the texture
  10702. * @param height Define the height of the texture
  10703. * @param scene Define the scene the texture belongs to
  10704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10707. * @returns the alpha texture
  10708. */
  10709. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10710. /**
  10711. * Creates a RGB texture from some data.
  10712. * @param data Define the texture data
  10713. * @param width Define the width of the texture
  10714. * @param height Define the height of the texture
  10715. * @param scene Define the scene the texture belongs to
  10716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10720. * @returns the RGB alpha texture
  10721. */
  10722. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10723. /**
  10724. * Creates a RGBA texture from some data.
  10725. * @param data Define the texture data
  10726. * @param width Define the width of the texture
  10727. * @param height Define the height of the texture
  10728. * @param scene Define the scene the texture belongs to
  10729. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10730. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10731. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10732. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10733. * @returns the RGBA texture
  10734. */
  10735. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10736. /**
  10737. * Creates a R texture from some data.
  10738. * @param data Define the texture data
  10739. * @param width Define the width of the texture
  10740. * @param height Define the height of the texture
  10741. * @param scene Define the scene the texture belongs to
  10742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10745. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10746. * @returns the R texture
  10747. */
  10748. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. interface AbstractScene {
  10753. /**
  10754. * The list of procedural textures added to the scene
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10756. */
  10757. proceduralTextures: Array<ProceduralTexture>;
  10758. }
  10759. /**
  10760. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10761. * in a given scene.
  10762. */
  10763. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10764. /**
  10765. * The component name helpfull to identify the component in the list of scene components.
  10766. */
  10767. readonly name: string;
  10768. /**
  10769. * The scene the component belongs to.
  10770. */
  10771. scene: Scene;
  10772. /**
  10773. * Creates a new instance of the component for the given scene
  10774. * @param scene Defines the scene to register the component in
  10775. */
  10776. constructor(scene: Scene);
  10777. /**
  10778. * Registers the component in a given scene
  10779. */
  10780. register(): void;
  10781. /**
  10782. * Rebuilds the elements related to this component in case of
  10783. * context lost for instance.
  10784. */
  10785. rebuild(): void;
  10786. /**
  10787. * Disposes the component and the associated ressources.
  10788. */
  10789. dispose(): void;
  10790. private _beforeClear;
  10791. }
  10792. }
  10793. declare module BABYLON {
  10794. interface ThinEngine {
  10795. /**
  10796. * Creates a new render target cube texture
  10797. * @param size defines the size of the texture
  10798. * @param options defines the options used to create the texture
  10799. * @returns a new render target cube texture stored in an InternalTexture
  10800. */
  10801. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /** @hidden */
  10806. export var proceduralVertexShader: {
  10807. name: string;
  10808. shader: string;
  10809. };
  10810. }
  10811. declare module BABYLON {
  10812. /**
  10813. * 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.
  10814. * This is the base class of any Procedural texture and contains most of the shareable code.
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10816. */
  10817. export class ProceduralTexture extends Texture {
  10818. isCube: boolean;
  10819. /**
  10820. * Define if the texture is enabled or not (disabled texture will not render)
  10821. */
  10822. isEnabled: boolean;
  10823. /**
  10824. * Define if the texture must be cleared before rendering (default is true)
  10825. */
  10826. autoClear: boolean;
  10827. /**
  10828. * Callback called when the texture is generated
  10829. */
  10830. onGenerated: () => void;
  10831. /**
  10832. * Event raised when the texture is generated
  10833. */
  10834. onGeneratedObservable: Observable<ProceduralTexture>;
  10835. /** @hidden */
  10836. _generateMipMaps: boolean;
  10837. /** @hidden **/
  10838. _effect: Effect;
  10839. /** @hidden */
  10840. _textures: {
  10841. [key: string]: Texture;
  10842. };
  10843. private _size;
  10844. private _currentRefreshId;
  10845. private _frameId;
  10846. private _refreshRate;
  10847. private _vertexBuffers;
  10848. private _indexBuffer;
  10849. private _uniforms;
  10850. private _samplers;
  10851. private _fragment;
  10852. private _floats;
  10853. private _ints;
  10854. private _floatsArrays;
  10855. private _colors3;
  10856. private _colors4;
  10857. private _vectors2;
  10858. private _vectors3;
  10859. private _matrices;
  10860. private _fallbackTexture;
  10861. private _fallbackTextureUsed;
  10862. private _engine;
  10863. private _cachedDefines;
  10864. private _contentUpdateId;
  10865. private _contentData;
  10866. /**
  10867. * Instantiates a new procedural texture.
  10868. * 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.
  10869. * This is the base class of any Procedural texture and contains most of the shareable code.
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10871. * @param name Define the name of the texture
  10872. * @param size Define the size of the texture to create
  10873. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10874. * @param scene Define the scene the texture belongs to
  10875. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10876. * @param generateMipMaps Define if the texture should creates mip maps or not
  10877. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10878. */
  10879. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10880. /**
  10881. * The effect that is created when initializing the post process.
  10882. * @returns The created effect corresponding the the postprocess.
  10883. */
  10884. getEffect(): Effect;
  10885. /**
  10886. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10887. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10888. */
  10889. getContent(): Nullable<ArrayBufferView>;
  10890. private _createIndexBuffer;
  10891. /** @hidden */
  10892. _rebuild(): void;
  10893. /**
  10894. * Resets the texture in order to recreate its associated resources.
  10895. * This can be called in case of context loss
  10896. */
  10897. reset(): void;
  10898. protected _getDefines(): string;
  10899. /**
  10900. * Is the texture ready to be used ? (rendered at least once)
  10901. * @returns true if ready, otherwise, false.
  10902. */
  10903. isReady(): boolean;
  10904. /**
  10905. * Resets the refresh counter of the texture and start bak from scratch.
  10906. * Could be useful to regenerate the texture if it is setup to render only once.
  10907. */
  10908. resetRefreshCounter(): void;
  10909. /**
  10910. * Set the fragment shader to use in order to render the texture.
  10911. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10912. */
  10913. setFragment(fragment: any): void;
  10914. /**
  10915. * Define the refresh rate of the texture or the rendering frequency.
  10916. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10917. */
  10918. get refreshRate(): number;
  10919. set refreshRate(value: number);
  10920. /** @hidden */
  10921. _shouldRender(): boolean;
  10922. /**
  10923. * Get the size the texture is rendering at.
  10924. * @returns the size (texture is always squared)
  10925. */
  10926. getRenderSize(): number;
  10927. /**
  10928. * Resize the texture to new value.
  10929. * @param size Define the new size the texture should have
  10930. * @param generateMipMaps Define whether the new texture should create mip maps
  10931. */
  10932. resize(size: number, generateMipMaps: boolean): void;
  10933. private _checkUniform;
  10934. /**
  10935. * Set a texture in the shader program used to render.
  10936. * @param name Define the name of the uniform samplers as defined in the shader
  10937. * @param texture Define the texture to bind to this sampler
  10938. * @return the texture itself allowing "fluent" like uniform updates
  10939. */
  10940. setTexture(name: string, texture: Texture): ProceduralTexture;
  10941. /**
  10942. * Set a float in the shader.
  10943. * @param name Define the name of the uniform as defined in the shader
  10944. * @param value Define the value to give to the uniform
  10945. * @return the texture itself allowing "fluent" like uniform updates
  10946. */
  10947. setFloat(name: string, value: number): ProceduralTexture;
  10948. /**
  10949. * Set a int in the shader.
  10950. * @param name Define the name of the uniform as defined in the shader
  10951. * @param value Define the value to give to the uniform
  10952. * @return the texture itself allowing "fluent" like uniform updates
  10953. */
  10954. setInt(name: string, value: number): ProceduralTexture;
  10955. /**
  10956. * Set an array of floats in the shader.
  10957. * @param name Define the name of the uniform as defined in the shader
  10958. * @param value Define the value to give to the uniform
  10959. * @return the texture itself allowing "fluent" like uniform updates
  10960. */
  10961. setFloats(name: string, value: number[]): ProceduralTexture;
  10962. /**
  10963. * Set a vec3 in the shader from a Color3.
  10964. * @param name Define the name of the uniform as defined in the shader
  10965. * @param value Define the value to give to the uniform
  10966. * @return the texture itself allowing "fluent" like uniform updates
  10967. */
  10968. setColor3(name: string, value: Color3): ProceduralTexture;
  10969. /**
  10970. * Set a vec4 in the shader from a Color4.
  10971. * @param name Define the name of the uniform as defined in the shader
  10972. * @param value Define the value to give to the uniform
  10973. * @return the texture itself allowing "fluent" like uniform updates
  10974. */
  10975. setColor4(name: string, value: Color4): ProceduralTexture;
  10976. /**
  10977. * Set a vec2 in the shader from a Vector2.
  10978. * @param name Define the name of the uniform as defined in the shader
  10979. * @param value Define the value to give to the uniform
  10980. * @return the texture itself allowing "fluent" like uniform updates
  10981. */
  10982. setVector2(name: string, value: Vector2): ProceduralTexture;
  10983. /**
  10984. * Set a vec3 in the shader from a Vector3.
  10985. * @param name Define the name of the uniform as defined in the shader
  10986. * @param value Define the value to give to the uniform
  10987. * @return the texture itself allowing "fluent" like uniform updates
  10988. */
  10989. setVector3(name: string, value: Vector3): ProceduralTexture;
  10990. /**
  10991. * Set a mat4 in the shader from a MAtrix.
  10992. * @param name Define the name of the uniform as defined in the shader
  10993. * @param value Define the value to give to the uniform
  10994. * @return the texture itself allowing "fluent" like uniform updates
  10995. */
  10996. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10997. /**
  10998. * Render the texture to its associated render target.
  10999. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11000. */
  11001. render(useCameraPostProcess?: boolean): void;
  11002. /**
  11003. * Clone the texture.
  11004. * @returns the cloned texture
  11005. */
  11006. clone(): ProceduralTexture;
  11007. /**
  11008. * Dispose the texture and release its asoociated resources.
  11009. */
  11010. dispose(): void;
  11011. }
  11012. }
  11013. declare module BABYLON {
  11014. /**
  11015. * This represents the base class for particle system in Babylon.
  11016. * 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.
  11017. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11018. * @example https://doc.babylonjs.com/babylon101/particles
  11019. */
  11020. export class BaseParticleSystem {
  11021. /**
  11022. * Source color is added to the destination color without alpha affecting the result
  11023. */
  11024. static BLENDMODE_ONEONE: number;
  11025. /**
  11026. * Blend current color and particle color using particle’s alpha
  11027. */
  11028. static BLENDMODE_STANDARD: number;
  11029. /**
  11030. * Add current color and particle color multiplied by particle’s alpha
  11031. */
  11032. static BLENDMODE_ADD: number;
  11033. /**
  11034. * Multiply current color with particle color
  11035. */
  11036. static BLENDMODE_MULTIPLY: number;
  11037. /**
  11038. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11039. */
  11040. static BLENDMODE_MULTIPLYADD: number;
  11041. /**
  11042. * List of animations used by the particle system.
  11043. */
  11044. animations: Animation[];
  11045. /**
  11046. * Gets or sets the unique id of the particle system
  11047. */
  11048. uniqueId: number;
  11049. /**
  11050. * The id of the Particle system.
  11051. */
  11052. id: string;
  11053. /**
  11054. * The friendly name of the Particle system.
  11055. */
  11056. name: string;
  11057. /**
  11058. * The rendering group used by the Particle system to chose when to render.
  11059. */
  11060. renderingGroupId: number;
  11061. /**
  11062. * The emitter represents the Mesh or position we are attaching the particle system to.
  11063. */
  11064. emitter: Nullable<AbstractMesh | Vector3>;
  11065. /**
  11066. * The maximum number of particles to emit per frame
  11067. */
  11068. emitRate: number;
  11069. /**
  11070. * If you want to launch only a few particles at once, that can be done, as well.
  11071. */
  11072. manualEmitCount: number;
  11073. /**
  11074. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11075. */
  11076. updateSpeed: number;
  11077. /**
  11078. * The amount of time the particle system is running (depends of the overall update speed).
  11079. */
  11080. targetStopDuration: number;
  11081. /**
  11082. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11083. */
  11084. disposeOnStop: boolean;
  11085. /**
  11086. * Minimum power of emitting particles.
  11087. */
  11088. minEmitPower: number;
  11089. /**
  11090. * Maximum power of emitting particles.
  11091. */
  11092. maxEmitPower: number;
  11093. /**
  11094. * Minimum life time of emitting particles.
  11095. */
  11096. minLifeTime: number;
  11097. /**
  11098. * Maximum life time of emitting particles.
  11099. */
  11100. maxLifeTime: number;
  11101. /**
  11102. * Minimum Size of emitting particles.
  11103. */
  11104. minSize: number;
  11105. /**
  11106. * Maximum Size of emitting particles.
  11107. */
  11108. maxSize: number;
  11109. /**
  11110. * Minimum scale of emitting particles on X axis.
  11111. */
  11112. minScaleX: number;
  11113. /**
  11114. * Maximum scale of emitting particles on X axis.
  11115. */
  11116. maxScaleX: number;
  11117. /**
  11118. * Minimum scale of emitting particles on Y axis.
  11119. */
  11120. minScaleY: number;
  11121. /**
  11122. * Maximum scale of emitting particles on Y axis.
  11123. */
  11124. maxScaleY: number;
  11125. /**
  11126. * Gets or sets the minimal initial rotation in radians.
  11127. */
  11128. minInitialRotation: number;
  11129. /**
  11130. * Gets or sets the maximal initial rotation in radians.
  11131. */
  11132. maxInitialRotation: number;
  11133. /**
  11134. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11135. */
  11136. minAngularSpeed: number;
  11137. /**
  11138. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11139. */
  11140. maxAngularSpeed: number;
  11141. /**
  11142. * The texture used to render each particle. (this can be a spritesheet)
  11143. */
  11144. particleTexture: Nullable<Texture>;
  11145. /**
  11146. * The layer mask we are rendering the particles through.
  11147. */
  11148. layerMask: number;
  11149. /**
  11150. * This can help using your own shader to render the particle system.
  11151. * The according effect will be created
  11152. */
  11153. customShader: any;
  11154. /**
  11155. * By default particle system starts as soon as they are created. This prevents the
  11156. * automatic start to happen and let you decide when to start emitting particles.
  11157. */
  11158. preventAutoStart: boolean;
  11159. private _noiseTexture;
  11160. /**
  11161. * Gets or sets a texture used to add random noise to particle positions
  11162. */
  11163. get noiseTexture(): Nullable<ProceduralTexture>;
  11164. set noiseTexture(value: Nullable<ProceduralTexture>);
  11165. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11166. noiseStrength: Vector3;
  11167. /**
  11168. * Callback triggered when the particle animation is ending.
  11169. */
  11170. onAnimationEnd: Nullable<() => void>;
  11171. /**
  11172. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11173. */
  11174. blendMode: number;
  11175. /**
  11176. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11177. * to override the particles.
  11178. */
  11179. forceDepthWrite: boolean;
  11180. /** 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 */
  11181. preWarmCycles: number;
  11182. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11183. preWarmStepOffset: number;
  11184. /**
  11185. * 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)
  11186. */
  11187. spriteCellChangeSpeed: number;
  11188. /**
  11189. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11190. */
  11191. startSpriteCellID: number;
  11192. /**
  11193. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11194. */
  11195. endSpriteCellID: number;
  11196. /**
  11197. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11198. */
  11199. spriteCellWidth: number;
  11200. /**
  11201. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11202. */
  11203. spriteCellHeight: number;
  11204. /**
  11205. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11206. */
  11207. spriteRandomStartCell: boolean;
  11208. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11209. translationPivot: Vector2;
  11210. /** @hidden */
  11211. protected _isAnimationSheetEnabled: boolean;
  11212. /**
  11213. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11214. */
  11215. beginAnimationOnStart: boolean;
  11216. /**
  11217. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11218. */
  11219. beginAnimationFrom: number;
  11220. /**
  11221. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11222. */
  11223. beginAnimationTo: number;
  11224. /**
  11225. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11226. */
  11227. beginAnimationLoop: boolean;
  11228. /**
  11229. * Gets or sets a world offset applied to all particles
  11230. */
  11231. worldOffset: Vector3;
  11232. /**
  11233. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11234. */
  11235. get isAnimationSheetEnabled(): boolean;
  11236. set isAnimationSheetEnabled(value: boolean);
  11237. /**
  11238. * Get hosting scene
  11239. * @returns the scene
  11240. */
  11241. getScene(): Scene;
  11242. /**
  11243. * You can use gravity if you want to give an orientation to your particles.
  11244. */
  11245. gravity: Vector3;
  11246. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11247. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11248. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11249. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11250. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11251. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11252. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11253. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11254. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11255. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11256. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11257. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11258. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11259. /**
  11260. * Defines the delay in milliseconds before starting the system (0 by default)
  11261. */
  11262. startDelay: number;
  11263. /**
  11264. * Gets the current list of drag gradients.
  11265. * You must use addDragGradient and removeDragGradient to udpate this list
  11266. * @returns the list of drag gradients
  11267. */
  11268. getDragGradients(): Nullable<Array<FactorGradient>>;
  11269. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11270. limitVelocityDamping: number;
  11271. /**
  11272. * Gets the current list of limit velocity gradients.
  11273. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11274. * @returns the list of limit velocity gradients
  11275. */
  11276. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11277. /**
  11278. * Gets the current list of color gradients.
  11279. * You must use addColorGradient and removeColorGradient to udpate this list
  11280. * @returns the list of color gradients
  11281. */
  11282. getColorGradients(): Nullable<Array<ColorGradient>>;
  11283. /**
  11284. * Gets the current list of size gradients.
  11285. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11286. * @returns the list of size gradients
  11287. */
  11288. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11289. /**
  11290. * Gets the current list of color remap gradients.
  11291. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11292. * @returns the list of color remap gradients
  11293. */
  11294. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11295. /**
  11296. * Gets the current list of alpha remap gradients.
  11297. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11298. * @returns the list of alpha remap gradients
  11299. */
  11300. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11301. /**
  11302. * Gets the current list of life time gradients.
  11303. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11304. * @returns the list of life time gradients
  11305. */
  11306. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11307. /**
  11308. * Gets the current list of angular speed gradients.
  11309. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11310. * @returns the list of angular speed gradients
  11311. */
  11312. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11313. /**
  11314. * Gets the current list of velocity gradients.
  11315. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11316. * @returns the list of velocity gradients
  11317. */
  11318. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11319. /**
  11320. * Gets the current list of start size gradients.
  11321. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11322. * @returns the list of start size gradients
  11323. */
  11324. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11325. /**
  11326. * Gets the current list of emit rate gradients.
  11327. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11328. * @returns the list of emit rate gradients
  11329. */
  11330. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11331. /**
  11332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11333. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11334. */
  11335. get direction1(): Vector3;
  11336. set direction1(value: Vector3);
  11337. /**
  11338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11339. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11340. */
  11341. get direction2(): Vector3;
  11342. set direction2(value: Vector3);
  11343. /**
  11344. * 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.
  11345. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11346. */
  11347. get minEmitBox(): Vector3;
  11348. set minEmitBox(value: Vector3);
  11349. /**
  11350. * 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.
  11351. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11352. */
  11353. get maxEmitBox(): Vector3;
  11354. set maxEmitBox(value: Vector3);
  11355. /**
  11356. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11357. */
  11358. color1: Color4;
  11359. /**
  11360. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11361. */
  11362. color2: Color4;
  11363. /**
  11364. * Color the particle will have at the end of its lifetime
  11365. */
  11366. colorDead: Color4;
  11367. /**
  11368. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11369. */
  11370. textureMask: Color4;
  11371. /**
  11372. * The particle emitter type defines the emitter used by the particle system.
  11373. * It can be for example box, sphere, or cone...
  11374. */
  11375. particleEmitterType: IParticleEmitterType;
  11376. /** @hidden */
  11377. _isSubEmitter: boolean;
  11378. /**
  11379. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11380. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11381. */
  11382. billboardMode: number;
  11383. protected _isBillboardBased: boolean;
  11384. /**
  11385. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11386. */
  11387. get isBillboardBased(): boolean;
  11388. set isBillboardBased(value: boolean);
  11389. /**
  11390. * The scene the particle system belongs to.
  11391. */
  11392. protected _scene: Scene;
  11393. /**
  11394. * Local cache of defines for image processing.
  11395. */
  11396. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11397. /**
  11398. * Default configuration related to image processing available in the standard Material.
  11399. */
  11400. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11401. /**
  11402. * Gets the image processing configuration used either in this material.
  11403. */
  11404. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11405. /**
  11406. * Sets the Default image processing configuration used either in the this material.
  11407. *
  11408. * If sets to null, the scene one is in use.
  11409. */
  11410. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11411. /**
  11412. * Attaches a new image processing configuration to the Standard Material.
  11413. * @param configuration
  11414. */
  11415. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11416. /** @hidden */
  11417. protected _reset(): void;
  11418. /** @hidden */
  11419. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11420. /**
  11421. * Instantiates a particle system.
  11422. * 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.
  11423. * @param name The name of the particle system
  11424. */
  11425. constructor(name: string);
  11426. /**
  11427. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11430. * @returns the emitter
  11431. */
  11432. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11433. /**
  11434. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11435. * @param radius The radius of the hemisphere to emit from
  11436. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11437. * @returns the emitter
  11438. */
  11439. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11440. /**
  11441. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11442. * @param radius The radius of the sphere to emit from
  11443. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11444. * @returns the emitter
  11445. */
  11446. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11447. /**
  11448. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11449. * @param radius The radius of the sphere to emit from
  11450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11452. * @returns the emitter
  11453. */
  11454. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11455. /**
  11456. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11457. * @param radius The radius of the emission cylinder
  11458. * @param height The height of the emission cylinder
  11459. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11460. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11461. * @returns the emitter
  11462. */
  11463. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11464. /**
  11465. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11466. * @param radius The radius of the cylinder to emit from
  11467. * @param height The height of the emission cylinder
  11468. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11471. * @returns the emitter
  11472. */
  11473. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11474. /**
  11475. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11476. * @param radius The radius of the cone to emit from
  11477. * @param angle The base angle of the cone
  11478. * @returns the emitter
  11479. */
  11480. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11481. /**
  11482. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11485. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11486. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11487. * @returns the emitter
  11488. */
  11489. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11490. }
  11491. }
  11492. declare module BABYLON {
  11493. /**
  11494. * Type of sub emitter
  11495. */
  11496. export enum SubEmitterType {
  11497. /**
  11498. * Attached to the particle over it's lifetime
  11499. */
  11500. ATTACHED = 0,
  11501. /**
  11502. * Created when the particle dies
  11503. */
  11504. END = 1
  11505. }
  11506. /**
  11507. * Sub emitter class used to emit particles from an existing particle
  11508. */
  11509. export class SubEmitter {
  11510. /**
  11511. * the particle system to be used by the sub emitter
  11512. */
  11513. particleSystem: ParticleSystem;
  11514. /**
  11515. * Type of the submitter (Default: END)
  11516. */
  11517. type: SubEmitterType;
  11518. /**
  11519. * 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)
  11520. * Note: This only is supported when using an emitter of type Mesh
  11521. */
  11522. inheritDirection: boolean;
  11523. /**
  11524. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11525. */
  11526. inheritedVelocityAmount: number;
  11527. /**
  11528. * Creates a sub emitter
  11529. * @param particleSystem the particle system to be used by the sub emitter
  11530. */
  11531. constructor(
  11532. /**
  11533. * the particle system to be used by the sub emitter
  11534. */
  11535. particleSystem: ParticleSystem);
  11536. /**
  11537. * Clones the sub emitter
  11538. * @returns the cloned sub emitter
  11539. */
  11540. clone(): SubEmitter;
  11541. /**
  11542. * Serialize current object to a JSON object
  11543. * @returns the serialized object
  11544. */
  11545. serialize(): any;
  11546. /** @hidden */
  11547. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11548. /**
  11549. * Creates a new SubEmitter from a serialized JSON version
  11550. * @param serializationObject defines the JSON object to read from
  11551. * @param scene defines the hosting scene
  11552. * @param rootUrl defines the rootUrl for data loading
  11553. * @returns a new SubEmitter
  11554. */
  11555. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11556. /** Release associated resources */
  11557. dispose(): void;
  11558. }
  11559. }
  11560. declare module BABYLON {
  11561. /** @hidden */
  11562. export var imageProcessingDeclaration: {
  11563. name: string;
  11564. shader: string;
  11565. };
  11566. }
  11567. declare module BABYLON {
  11568. /** @hidden */
  11569. export var imageProcessingFunctions: {
  11570. name: string;
  11571. shader: string;
  11572. };
  11573. }
  11574. declare module BABYLON {
  11575. /** @hidden */
  11576. export var particlesPixelShader: {
  11577. name: string;
  11578. shader: string;
  11579. };
  11580. }
  11581. declare module BABYLON {
  11582. /** @hidden */
  11583. export var particlesVertexShader: {
  11584. name: string;
  11585. shader: string;
  11586. };
  11587. }
  11588. declare module BABYLON {
  11589. /**
  11590. * This represents a particle system in Babylon.
  11591. * 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.
  11592. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11593. * @example https://doc.babylonjs.com/babylon101/particles
  11594. */
  11595. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11596. /**
  11597. * Billboard mode will only apply to Y axis
  11598. */
  11599. static readonly BILLBOARDMODE_Y: number;
  11600. /**
  11601. * Billboard mode will apply to all axes
  11602. */
  11603. static readonly BILLBOARDMODE_ALL: number;
  11604. /**
  11605. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11606. */
  11607. static readonly BILLBOARDMODE_STRETCHED: number;
  11608. /**
  11609. * This function can be defined to provide custom update for active particles.
  11610. * This function will be called instead of regular update (age, position, color, etc.).
  11611. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11612. */
  11613. updateFunction: (particles: Particle[]) => void;
  11614. private _emitterWorldMatrix;
  11615. /**
  11616. * This function can be defined to specify initial direction for every new particle.
  11617. * It by default use the emitterType defined function
  11618. */
  11619. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11620. /**
  11621. * This function can be defined to specify initial position for every new particle.
  11622. * It by default use the emitterType defined function
  11623. */
  11624. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11625. /**
  11626. * @hidden
  11627. */
  11628. _inheritedVelocityOffset: Vector3;
  11629. /**
  11630. * An event triggered when the system is disposed
  11631. */
  11632. onDisposeObservable: Observable<ParticleSystem>;
  11633. private _onDisposeObserver;
  11634. /**
  11635. * Sets a callback that will be triggered when the system is disposed
  11636. */
  11637. set onDispose(callback: () => void);
  11638. private _particles;
  11639. private _epsilon;
  11640. private _capacity;
  11641. private _stockParticles;
  11642. private _newPartsExcess;
  11643. private _vertexData;
  11644. private _vertexBuffer;
  11645. private _vertexBuffers;
  11646. private _spriteBuffer;
  11647. private _indexBuffer;
  11648. private _effect;
  11649. private _customEffect;
  11650. private _cachedDefines;
  11651. private _scaledColorStep;
  11652. private _colorDiff;
  11653. private _scaledDirection;
  11654. private _scaledGravity;
  11655. private _currentRenderId;
  11656. private _alive;
  11657. private _useInstancing;
  11658. private _started;
  11659. private _stopped;
  11660. private _actualFrame;
  11661. private _scaledUpdateSpeed;
  11662. private _vertexBufferSize;
  11663. /** @hidden */
  11664. _currentEmitRateGradient: Nullable<FactorGradient>;
  11665. /** @hidden */
  11666. _currentEmitRate1: number;
  11667. /** @hidden */
  11668. _currentEmitRate2: number;
  11669. /** @hidden */
  11670. _currentStartSizeGradient: Nullable<FactorGradient>;
  11671. /** @hidden */
  11672. _currentStartSize1: number;
  11673. /** @hidden */
  11674. _currentStartSize2: number;
  11675. private readonly _rawTextureWidth;
  11676. private _rampGradientsTexture;
  11677. private _useRampGradients;
  11678. /** Gets or sets a boolean indicating that ramp gradients must be used
  11679. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11680. */
  11681. get useRampGradients(): boolean;
  11682. set useRampGradients(value: boolean);
  11683. /**
  11684. * 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.
  11685. * 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: [])
  11686. */
  11687. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11688. private _subEmitters;
  11689. /**
  11690. * @hidden
  11691. * If the particle systems emitter should be disposed when the particle system is disposed
  11692. */
  11693. _disposeEmitterOnDispose: boolean;
  11694. /**
  11695. * The current active Sub-systems, this property is used by the root particle system only.
  11696. */
  11697. activeSubSystems: Array<ParticleSystem>;
  11698. /**
  11699. * Specifies if the particles are updated in emitter local space or world space
  11700. */
  11701. isLocal: boolean;
  11702. private _rootParticleSystem;
  11703. /**
  11704. * Gets the current list of active particles
  11705. */
  11706. get particles(): Particle[];
  11707. /**
  11708. * Gets the number of particles active at the same time.
  11709. * @returns The number of active particles.
  11710. */
  11711. getActiveCount(): number;
  11712. /**
  11713. * Returns the string "ParticleSystem"
  11714. * @returns a string containing the class name
  11715. */
  11716. getClassName(): string;
  11717. /**
  11718. * Gets a boolean indicating that the system is stopping
  11719. * @returns true if the system is currently stopping
  11720. */
  11721. isStopping(): boolean;
  11722. /**
  11723. * Instantiates a particle system.
  11724. * 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.
  11725. * @param name The name of the particle system
  11726. * @param capacity The max number of particles alive at the same time
  11727. * @param scene The scene the particle system belongs to
  11728. * @param customEffect a custom effect used to change the way particles are rendered by default
  11729. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11730. * @param epsilon Offset used to render the particles
  11731. */
  11732. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11733. private _addFactorGradient;
  11734. private _removeFactorGradient;
  11735. /**
  11736. * Adds a new life time gradient
  11737. * @param gradient defines the gradient to use (between 0 and 1)
  11738. * @param factor defines the life time factor to affect to the specified gradient
  11739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11740. * @returns the current particle system
  11741. */
  11742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11743. /**
  11744. * Remove a specific life time gradient
  11745. * @param gradient defines the gradient to remove
  11746. * @returns the current particle system
  11747. */
  11748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11749. /**
  11750. * Adds a new size gradient
  11751. * @param gradient defines the gradient to use (between 0 and 1)
  11752. * @param factor defines the size factor to affect to the specified gradient
  11753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11754. * @returns the current particle system
  11755. */
  11756. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11757. /**
  11758. * Remove a specific size gradient
  11759. * @param gradient defines the gradient to remove
  11760. * @returns the current particle system
  11761. */
  11762. removeSizeGradient(gradient: number): IParticleSystem;
  11763. /**
  11764. * Adds a new color remap gradient
  11765. * @param gradient defines the gradient to use (between 0 and 1)
  11766. * @param min defines the color remap minimal range
  11767. * @param max defines the color remap maximal range
  11768. * @returns the current particle system
  11769. */
  11770. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11771. /**
  11772. * Remove a specific color remap gradient
  11773. * @param gradient defines the gradient to remove
  11774. * @returns the current particle system
  11775. */
  11776. removeColorRemapGradient(gradient: number): IParticleSystem;
  11777. /**
  11778. * Adds a new alpha remap gradient
  11779. * @param gradient defines the gradient to use (between 0 and 1)
  11780. * @param min defines the alpha remap minimal range
  11781. * @param max defines the alpha remap maximal range
  11782. * @returns the current particle system
  11783. */
  11784. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11785. /**
  11786. * Remove a specific alpha remap gradient
  11787. * @param gradient defines the gradient to remove
  11788. * @returns the current particle system
  11789. */
  11790. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11791. /**
  11792. * Adds a new angular speed gradient
  11793. * @param gradient defines the gradient to use (between 0 and 1)
  11794. * @param factor defines the angular speed to affect to the specified gradient
  11795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11796. * @returns the current particle system
  11797. */
  11798. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11799. /**
  11800. * Remove a specific angular speed gradient
  11801. * @param gradient defines the gradient to remove
  11802. * @returns the current particle system
  11803. */
  11804. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11805. /**
  11806. * Adds a new velocity gradient
  11807. * @param gradient defines the gradient to use (between 0 and 1)
  11808. * @param factor defines the velocity to affect to the specified gradient
  11809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11810. * @returns the current particle system
  11811. */
  11812. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11813. /**
  11814. * Remove a specific velocity gradient
  11815. * @param gradient defines the gradient to remove
  11816. * @returns the current particle system
  11817. */
  11818. removeVelocityGradient(gradient: number): IParticleSystem;
  11819. /**
  11820. * Adds a new limit velocity gradient
  11821. * @param gradient defines the gradient to use (between 0 and 1)
  11822. * @param factor defines the limit velocity value to affect to the specified gradient
  11823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11824. * @returns the current particle system
  11825. */
  11826. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11827. /**
  11828. * Remove a specific limit velocity gradient
  11829. * @param gradient defines the gradient to remove
  11830. * @returns the current particle system
  11831. */
  11832. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11833. /**
  11834. * Adds a new drag gradient
  11835. * @param gradient defines the gradient to use (between 0 and 1)
  11836. * @param factor defines the drag value to affect to the specified gradient
  11837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11838. * @returns the current particle system
  11839. */
  11840. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11841. /**
  11842. * Remove a specific drag gradient
  11843. * @param gradient defines the gradient to remove
  11844. * @returns the current particle system
  11845. */
  11846. removeDragGradient(gradient: number): IParticleSystem;
  11847. /**
  11848. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11849. * @param gradient defines the gradient to use (between 0 and 1)
  11850. * @param factor defines the emit rate value to affect to the specified gradient
  11851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11852. * @returns the current particle system
  11853. */
  11854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11855. /**
  11856. * Remove a specific emit rate gradient
  11857. * @param gradient defines the gradient to remove
  11858. * @returns the current particle system
  11859. */
  11860. removeEmitRateGradient(gradient: number): IParticleSystem;
  11861. /**
  11862. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11863. * @param gradient defines the gradient to use (between 0 and 1)
  11864. * @param factor defines the start size value to affect to the specified gradient
  11865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11866. * @returns the current particle system
  11867. */
  11868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11869. /**
  11870. * Remove a specific start size gradient
  11871. * @param gradient defines the gradient to remove
  11872. * @returns the current particle system
  11873. */
  11874. removeStartSizeGradient(gradient: number): IParticleSystem;
  11875. private _createRampGradientTexture;
  11876. /**
  11877. * Gets the current list of ramp gradients.
  11878. * You must use addRampGradient and removeRampGradient to udpate this list
  11879. * @returns the list of ramp gradients
  11880. */
  11881. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11882. /**
  11883. * Adds a new ramp gradient used to remap particle colors
  11884. * @param gradient defines the gradient to use (between 0 and 1)
  11885. * @param color defines the color to affect to the specified gradient
  11886. * @returns the current particle system
  11887. */
  11888. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11889. /**
  11890. * Remove a specific ramp gradient
  11891. * @param gradient defines the gradient to remove
  11892. * @returns the current particle system
  11893. */
  11894. removeRampGradient(gradient: number): ParticleSystem;
  11895. /**
  11896. * Adds a new color gradient
  11897. * @param gradient defines the gradient to use (between 0 and 1)
  11898. * @param color1 defines the color to affect to the specified gradient
  11899. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11900. * @returns this particle system
  11901. */
  11902. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11903. /**
  11904. * Remove a specific color gradient
  11905. * @param gradient defines the gradient to remove
  11906. * @returns this particle system
  11907. */
  11908. removeColorGradient(gradient: number): IParticleSystem;
  11909. private _fetchR;
  11910. protected _reset(): void;
  11911. private _resetEffect;
  11912. private _createVertexBuffers;
  11913. private _createIndexBuffer;
  11914. /**
  11915. * Gets the maximum number of particles active at the same time.
  11916. * @returns The max number of active particles.
  11917. */
  11918. getCapacity(): number;
  11919. /**
  11920. * Gets whether there are still active particles in the system.
  11921. * @returns True if it is alive, otherwise false.
  11922. */
  11923. isAlive(): boolean;
  11924. /**
  11925. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11926. * @returns True if it has been started, otherwise false.
  11927. */
  11928. isStarted(): boolean;
  11929. private _prepareSubEmitterInternalArray;
  11930. /**
  11931. * Starts the particle system and begins to emit
  11932. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11933. */
  11934. start(delay?: number): void;
  11935. /**
  11936. * Stops the particle system.
  11937. * @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.
  11938. */
  11939. stop(stopSubEmitters?: boolean): void;
  11940. /**
  11941. * Remove all active particles
  11942. */
  11943. reset(): void;
  11944. /**
  11945. * @hidden (for internal use only)
  11946. */
  11947. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11948. /**
  11949. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11950. * Its lifetime will start back at 0.
  11951. */
  11952. recycleParticle: (particle: Particle) => void;
  11953. private _stopSubEmitters;
  11954. private _createParticle;
  11955. private _removeFromRoot;
  11956. private _emitFromParticle;
  11957. private _update;
  11958. /** @hidden */
  11959. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11960. /** @hidden */
  11961. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11962. /** @hidden */
  11963. private _getEffect;
  11964. /**
  11965. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11966. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11967. */
  11968. animate(preWarmOnly?: boolean): void;
  11969. private _appendParticleVertices;
  11970. /**
  11971. * Rebuilds the particle system.
  11972. */
  11973. rebuild(): void;
  11974. /**
  11975. * Is this system ready to be used/rendered
  11976. * @return true if the system is ready
  11977. */
  11978. isReady(): boolean;
  11979. private _render;
  11980. /**
  11981. * Renders the particle system in its current state.
  11982. * @returns the current number of particles
  11983. */
  11984. render(): number;
  11985. /**
  11986. * Disposes the particle system and free the associated resources
  11987. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11988. */
  11989. dispose(disposeTexture?: boolean): void;
  11990. /**
  11991. * Clones the particle system.
  11992. * @param name The name of the cloned object
  11993. * @param newEmitter The new emitter to use
  11994. * @returns the cloned particle system
  11995. */
  11996. clone(name: string, newEmitter: any): ParticleSystem;
  11997. /**
  11998. * Serializes the particle system to a JSON object.
  11999. * @returns the JSON object
  12000. */
  12001. serialize(): any;
  12002. /** @hidden */
  12003. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12004. /** @hidden */
  12005. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12006. /**
  12007. * Parses a JSON object to create a particle system.
  12008. * @param parsedParticleSystem The JSON object to parse
  12009. * @param scene The scene to create the particle system in
  12010. * @param rootUrl The root url to use to load external dependencies like texture
  12011. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12012. * @returns the Parsed particle system
  12013. */
  12014. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12015. }
  12016. }
  12017. declare module BABYLON {
  12018. /**
  12019. * A particle represents one of the element emitted by a particle system.
  12020. * This is mainly define by its coordinates, direction, velocity and age.
  12021. */
  12022. export class Particle {
  12023. /**
  12024. * The particle system the particle belongs to.
  12025. */
  12026. particleSystem: ParticleSystem;
  12027. private static _Count;
  12028. /**
  12029. * Unique ID of the particle
  12030. */
  12031. id: number;
  12032. /**
  12033. * The world position of the particle in the scene.
  12034. */
  12035. position: Vector3;
  12036. /**
  12037. * The world direction of the particle in the scene.
  12038. */
  12039. direction: Vector3;
  12040. /**
  12041. * The color of the particle.
  12042. */
  12043. color: Color4;
  12044. /**
  12045. * The color change of the particle per step.
  12046. */
  12047. colorStep: Color4;
  12048. /**
  12049. * Defines how long will the life of the particle be.
  12050. */
  12051. lifeTime: number;
  12052. /**
  12053. * The current age of the particle.
  12054. */
  12055. age: number;
  12056. /**
  12057. * The current size of the particle.
  12058. */
  12059. size: number;
  12060. /**
  12061. * The current scale of the particle.
  12062. */
  12063. scale: Vector2;
  12064. /**
  12065. * The current angle of the particle.
  12066. */
  12067. angle: number;
  12068. /**
  12069. * Defines how fast is the angle changing.
  12070. */
  12071. angularSpeed: number;
  12072. /**
  12073. * Defines the cell index used by the particle to be rendered from a sprite.
  12074. */
  12075. cellIndex: number;
  12076. /**
  12077. * The information required to support color remapping
  12078. */
  12079. remapData: Vector4;
  12080. /** @hidden */
  12081. _randomCellOffset?: number;
  12082. /** @hidden */
  12083. _initialDirection: Nullable<Vector3>;
  12084. /** @hidden */
  12085. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12086. /** @hidden */
  12087. _initialStartSpriteCellID: number;
  12088. /** @hidden */
  12089. _initialEndSpriteCellID: number;
  12090. /** @hidden */
  12091. _currentColorGradient: Nullable<ColorGradient>;
  12092. /** @hidden */
  12093. _currentColor1: Color4;
  12094. /** @hidden */
  12095. _currentColor2: Color4;
  12096. /** @hidden */
  12097. _currentSizeGradient: Nullable<FactorGradient>;
  12098. /** @hidden */
  12099. _currentSize1: number;
  12100. /** @hidden */
  12101. _currentSize2: number;
  12102. /** @hidden */
  12103. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12104. /** @hidden */
  12105. _currentAngularSpeed1: number;
  12106. /** @hidden */
  12107. _currentAngularSpeed2: number;
  12108. /** @hidden */
  12109. _currentVelocityGradient: Nullable<FactorGradient>;
  12110. /** @hidden */
  12111. _currentVelocity1: number;
  12112. /** @hidden */
  12113. _currentVelocity2: number;
  12114. /** @hidden */
  12115. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12116. /** @hidden */
  12117. _currentLimitVelocity1: number;
  12118. /** @hidden */
  12119. _currentLimitVelocity2: number;
  12120. /** @hidden */
  12121. _currentDragGradient: Nullable<FactorGradient>;
  12122. /** @hidden */
  12123. _currentDrag1: number;
  12124. /** @hidden */
  12125. _currentDrag2: number;
  12126. /** @hidden */
  12127. _randomNoiseCoordinates1: Vector3;
  12128. /** @hidden */
  12129. _randomNoiseCoordinates2: Vector3;
  12130. /** @hidden */
  12131. _localPosition?: Vector3;
  12132. /**
  12133. * Creates a new instance Particle
  12134. * @param particleSystem the particle system the particle belongs to
  12135. */
  12136. constructor(
  12137. /**
  12138. * The particle system the particle belongs to.
  12139. */
  12140. particleSystem: ParticleSystem);
  12141. private updateCellInfoFromSystem;
  12142. /**
  12143. * Defines how the sprite cell index is updated for the particle
  12144. */
  12145. updateCellIndex(): void;
  12146. /** @hidden */
  12147. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12148. /** @hidden */
  12149. _inheritParticleInfoToSubEmitters(): void;
  12150. /** @hidden */
  12151. _reset(): void;
  12152. /**
  12153. * Copy the properties of particle to another one.
  12154. * @param other the particle to copy the information to.
  12155. */
  12156. copyTo(other: Particle): void;
  12157. }
  12158. }
  12159. declare module BABYLON {
  12160. /**
  12161. * Particle emitter represents a volume emitting particles.
  12162. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12163. */
  12164. export interface IParticleEmitterType {
  12165. /**
  12166. * Called by the particle System when the direction is computed for the created particle.
  12167. * @param worldMatrix is the world matrix of the particle system
  12168. * @param directionToUpdate is the direction vector to update with the result
  12169. * @param particle is the particle we are computed the direction for
  12170. * @param isLocal defines if the direction should be set in local space
  12171. */
  12172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12173. /**
  12174. * Called by the particle System when the position is computed for the created particle.
  12175. * @param worldMatrix is the world matrix of the particle system
  12176. * @param positionToUpdate is the position vector to update with the result
  12177. * @param particle is the particle we are computed the position for
  12178. * @param isLocal defines if the position should be set in local space
  12179. */
  12180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12181. /**
  12182. * Clones the current emitter and returns a copy of it
  12183. * @returns the new emitter
  12184. */
  12185. clone(): IParticleEmitterType;
  12186. /**
  12187. * Called by the GPUParticleSystem to setup the update shader
  12188. * @param effect defines the update shader
  12189. */
  12190. applyToShader(effect: Effect): void;
  12191. /**
  12192. * Returns a string to use to update the GPU particles update shader
  12193. * @returns the effect defines string
  12194. */
  12195. getEffectDefines(): string;
  12196. /**
  12197. * Returns a string representing the class name
  12198. * @returns a string containing the class name
  12199. */
  12200. getClassName(): string;
  12201. /**
  12202. * Serializes the particle system to a JSON object.
  12203. * @returns the JSON object
  12204. */
  12205. serialize(): any;
  12206. /**
  12207. * Parse properties from a JSON object
  12208. * @param serializationObject defines the JSON object
  12209. * @param scene defines the hosting scene
  12210. */
  12211. parse(serializationObject: any, scene: Scene): void;
  12212. }
  12213. }
  12214. declare module BABYLON {
  12215. /**
  12216. * Particle emitter emitting particles from the inside of a box.
  12217. * It emits the particles randomly between 2 given directions.
  12218. */
  12219. export class BoxParticleEmitter implements IParticleEmitterType {
  12220. /**
  12221. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12222. */
  12223. direction1: Vector3;
  12224. /**
  12225. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12226. */
  12227. direction2: Vector3;
  12228. /**
  12229. * 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.
  12230. */
  12231. minEmitBox: Vector3;
  12232. /**
  12233. * 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.
  12234. */
  12235. maxEmitBox: Vector3;
  12236. /**
  12237. * Creates a new instance BoxParticleEmitter
  12238. */
  12239. constructor();
  12240. /**
  12241. * Called by the particle System when the direction is computed for the created particle.
  12242. * @param worldMatrix is the world matrix of the particle system
  12243. * @param directionToUpdate is the direction vector to update with the result
  12244. * @param particle is the particle we are computed the direction for
  12245. * @param isLocal defines if the direction should be set in local space
  12246. */
  12247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12248. /**
  12249. * Called by the particle System when the position is computed for the created particle.
  12250. * @param worldMatrix is the world matrix of the particle system
  12251. * @param positionToUpdate is the position vector to update with the result
  12252. * @param particle is the particle we are computed the position for
  12253. * @param isLocal defines if the position should be set in local space
  12254. */
  12255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12256. /**
  12257. * Clones the current emitter and returns a copy of it
  12258. * @returns the new emitter
  12259. */
  12260. clone(): BoxParticleEmitter;
  12261. /**
  12262. * Called by the GPUParticleSystem to setup the update shader
  12263. * @param effect defines the update shader
  12264. */
  12265. applyToShader(effect: Effect): void;
  12266. /**
  12267. * Returns a string to use to update the GPU particles update shader
  12268. * @returns a string containng the defines string
  12269. */
  12270. getEffectDefines(): string;
  12271. /**
  12272. * Returns the string "BoxParticleEmitter"
  12273. * @returns a string containing the class name
  12274. */
  12275. getClassName(): string;
  12276. /**
  12277. * Serializes the particle system to a JSON object.
  12278. * @returns the JSON object
  12279. */
  12280. serialize(): any;
  12281. /**
  12282. * Parse properties from a JSON object
  12283. * @param serializationObject defines the JSON object
  12284. */
  12285. parse(serializationObject: any): void;
  12286. }
  12287. }
  12288. declare module BABYLON {
  12289. /**
  12290. * Particle emitter emitting particles from the inside of a cone.
  12291. * It emits the particles alongside the cone volume from the base to the particle.
  12292. * The emission direction might be randomized.
  12293. */
  12294. export class ConeParticleEmitter implements IParticleEmitterType {
  12295. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12296. directionRandomizer: number;
  12297. private _radius;
  12298. private _angle;
  12299. private _height;
  12300. /**
  12301. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12302. */
  12303. radiusRange: number;
  12304. /**
  12305. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12306. */
  12307. heightRange: number;
  12308. /**
  12309. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12310. */
  12311. emitFromSpawnPointOnly: boolean;
  12312. /**
  12313. * Gets or sets the radius of the emission cone
  12314. */
  12315. get radius(): number;
  12316. set radius(value: number);
  12317. /**
  12318. * Gets or sets the angle of the emission cone
  12319. */
  12320. get angle(): number;
  12321. set angle(value: number);
  12322. private _buildHeight;
  12323. /**
  12324. * Creates a new instance ConeParticleEmitter
  12325. * @param radius the radius of the emission cone (1 by default)
  12326. * @param angle the cone base angle (PI by default)
  12327. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12328. */
  12329. constructor(radius?: number, angle?: number,
  12330. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12331. directionRandomizer?: number);
  12332. /**
  12333. * Called by the particle System when the direction is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param directionToUpdate is the direction vector to update with the result
  12336. * @param particle is the particle we are computed the direction for
  12337. * @param isLocal defines if the direction should be set in local space
  12338. */
  12339. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12340. /**
  12341. * Called by the particle System when the position is computed for the created particle.
  12342. * @param worldMatrix is the world matrix of the particle system
  12343. * @param positionToUpdate is the position vector to update with the result
  12344. * @param particle is the particle we are computed the position for
  12345. * @param isLocal defines if the position should be set in local space
  12346. */
  12347. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12348. /**
  12349. * Clones the current emitter and returns a copy of it
  12350. * @returns the new emitter
  12351. */
  12352. clone(): ConeParticleEmitter;
  12353. /**
  12354. * Called by the GPUParticleSystem to setup the update shader
  12355. * @param effect defines the update shader
  12356. */
  12357. applyToShader(effect: Effect): void;
  12358. /**
  12359. * Returns a string to use to update the GPU particles update shader
  12360. * @returns a string containng the defines string
  12361. */
  12362. getEffectDefines(): string;
  12363. /**
  12364. * Returns the string "ConeParticleEmitter"
  12365. * @returns a string containing the class name
  12366. */
  12367. getClassName(): string;
  12368. /**
  12369. * Serializes the particle system to a JSON object.
  12370. * @returns the JSON object
  12371. */
  12372. serialize(): any;
  12373. /**
  12374. * Parse properties from a JSON object
  12375. * @param serializationObject defines the JSON object
  12376. */
  12377. parse(serializationObject: any): void;
  12378. }
  12379. }
  12380. declare module BABYLON {
  12381. /**
  12382. * Particle emitter emitting particles from the inside of a cylinder.
  12383. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12384. */
  12385. export class CylinderParticleEmitter implements IParticleEmitterType {
  12386. /**
  12387. * The radius of the emission cylinder.
  12388. */
  12389. radius: number;
  12390. /**
  12391. * The height of the emission cylinder.
  12392. */
  12393. height: number;
  12394. /**
  12395. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12396. */
  12397. radiusRange: number;
  12398. /**
  12399. * How much to randomize the particle direction [0-1].
  12400. */
  12401. directionRandomizer: number;
  12402. /**
  12403. * Creates a new instance CylinderParticleEmitter
  12404. * @param radius the radius of the emission cylinder (1 by default)
  12405. * @param height the height of the emission cylinder (1 by default)
  12406. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12407. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12408. */
  12409. constructor(
  12410. /**
  12411. * The radius of the emission cylinder.
  12412. */
  12413. radius?: number,
  12414. /**
  12415. * The height of the emission cylinder.
  12416. */
  12417. height?: number,
  12418. /**
  12419. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12420. */
  12421. radiusRange?: number,
  12422. /**
  12423. * How much to randomize the particle direction [0-1].
  12424. */
  12425. directionRandomizer?: number);
  12426. /**
  12427. * Called by the particle System when the direction is computed for the created particle.
  12428. * @param worldMatrix is the world matrix of the particle system
  12429. * @param directionToUpdate is the direction vector to update with the result
  12430. * @param particle is the particle we are computed the direction for
  12431. * @param isLocal defines if the direction should be set in local space
  12432. */
  12433. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12434. /**
  12435. * Called by the particle System when the position is computed for the created particle.
  12436. * @param worldMatrix is the world matrix of the particle system
  12437. * @param positionToUpdate is the position vector to update with the result
  12438. * @param particle is the particle we are computed the position for
  12439. * @param isLocal defines if the position should be set in local space
  12440. */
  12441. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12442. /**
  12443. * Clones the current emitter and returns a copy of it
  12444. * @returns the new emitter
  12445. */
  12446. clone(): CylinderParticleEmitter;
  12447. /**
  12448. * Called by the GPUParticleSystem to setup the update shader
  12449. * @param effect defines the update shader
  12450. */
  12451. applyToShader(effect: Effect): void;
  12452. /**
  12453. * Returns a string to use to update the GPU particles update shader
  12454. * @returns a string containng the defines string
  12455. */
  12456. getEffectDefines(): string;
  12457. /**
  12458. * Returns the string "CylinderParticleEmitter"
  12459. * @returns a string containing the class name
  12460. */
  12461. getClassName(): string;
  12462. /**
  12463. * Serializes the particle system to a JSON object.
  12464. * @returns the JSON object
  12465. */
  12466. serialize(): any;
  12467. /**
  12468. * Parse properties from a JSON object
  12469. * @param serializationObject defines the JSON object
  12470. */
  12471. parse(serializationObject: any): void;
  12472. }
  12473. /**
  12474. * Particle emitter emitting particles from the inside of a cylinder.
  12475. * It emits the particles randomly between two vectors.
  12476. */
  12477. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12478. /**
  12479. * The min limit of the emission direction.
  12480. */
  12481. direction1: Vector3;
  12482. /**
  12483. * The max limit of the emission direction.
  12484. */
  12485. direction2: Vector3;
  12486. /**
  12487. * Creates a new instance CylinderDirectedParticleEmitter
  12488. * @param radius the radius of the emission cylinder (1 by default)
  12489. * @param height the height of the emission cylinder (1 by default)
  12490. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12491. * @param direction1 the min limit of the emission direction (up vector by default)
  12492. * @param direction2 the max limit of the emission direction (up vector by default)
  12493. */
  12494. constructor(radius?: number, height?: number, radiusRange?: number,
  12495. /**
  12496. * The min limit of the emission direction.
  12497. */
  12498. direction1?: Vector3,
  12499. /**
  12500. * The max limit of the emission direction.
  12501. */
  12502. direction2?: Vector3);
  12503. /**
  12504. * Called by the particle System when the direction is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param directionToUpdate is the direction vector to update with the result
  12507. * @param particle is the particle we are computed the direction for
  12508. */
  12509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Clones the current emitter and returns a copy of it
  12512. * @returns the new emitter
  12513. */
  12514. clone(): CylinderDirectedParticleEmitter;
  12515. /**
  12516. * Called by the GPUParticleSystem to setup the update shader
  12517. * @param effect defines the update shader
  12518. */
  12519. applyToShader(effect: Effect): void;
  12520. /**
  12521. * Returns a string to use to update the GPU particles update shader
  12522. * @returns a string containng the defines string
  12523. */
  12524. getEffectDefines(): string;
  12525. /**
  12526. * Returns the string "CylinderDirectedParticleEmitter"
  12527. * @returns a string containing the class name
  12528. */
  12529. getClassName(): string;
  12530. /**
  12531. * Serializes the particle system to a JSON object.
  12532. * @returns the JSON object
  12533. */
  12534. serialize(): any;
  12535. /**
  12536. * Parse properties from a JSON object
  12537. * @param serializationObject defines the JSON object
  12538. */
  12539. parse(serializationObject: any): void;
  12540. }
  12541. }
  12542. declare module BABYLON {
  12543. /**
  12544. * Particle emitter emitting particles from the inside of a hemisphere.
  12545. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12546. */
  12547. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12548. /**
  12549. * The radius of the emission hemisphere.
  12550. */
  12551. radius: number;
  12552. /**
  12553. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12554. */
  12555. radiusRange: number;
  12556. /**
  12557. * How much to randomize the particle direction [0-1].
  12558. */
  12559. directionRandomizer: number;
  12560. /**
  12561. * Creates a new instance HemisphericParticleEmitter
  12562. * @param radius the radius of the emission hemisphere (1 by default)
  12563. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12564. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12565. */
  12566. constructor(
  12567. /**
  12568. * The radius of the emission hemisphere.
  12569. */
  12570. radius?: number,
  12571. /**
  12572. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12573. */
  12574. radiusRange?: number,
  12575. /**
  12576. * How much to randomize the particle direction [0-1].
  12577. */
  12578. directionRandomizer?: number);
  12579. /**
  12580. * Called by the particle System when the direction is computed for the created particle.
  12581. * @param worldMatrix is the world matrix of the particle system
  12582. * @param directionToUpdate is the direction vector to update with the result
  12583. * @param particle is the particle we are computed the direction for
  12584. * @param isLocal defines if the direction should be set in local space
  12585. */
  12586. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12587. /**
  12588. * Called by the particle System when the position is computed for the created particle.
  12589. * @param worldMatrix is the world matrix of the particle system
  12590. * @param positionToUpdate is the position vector to update with the result
  12591. * @param particle is the particle we are computed the position for
  12592. * @param isLocal defines if the position should be set in local space
  12593. */
  12594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12595. /**
  12596. * Clones the current emitter and returns a copy of it
  12597. * @returns the new emitter
  12598. */
  12599. clone(): HemisphericParticleEmitter;
  12600. /**
  12601. * Called by the GPUParticleSystem to setup the update shader
  12602. * @param effect defines the update shader
  12603. */
  12604. applyToShader(effect: Effect): void;
  12605. /**
  12606. * Returns a string to use to update the GPU particles update shader
  12607. * @returns a string containng the defines string
  12608. */
  12609. getEffectDefines(): string;
  12610. /**
  12611. * Returns the string "HemisphericParticleEmitter"
  12612. * @returns a string containing the class name
  12613. */
  12614. getClassName(): string;
  12615. /**
  12616. * Serializes the particle system to a JSON object.
  12617. * @returns the JSON object
  12618. */
  12619. serialize(): any;
  12620. /**
  12621. * Parse properties from a JSON object
  12622. * @param serializationObject defines the JSON object
  12623. */
  12624. parse(serializationObject: any): void;
  12625. }
  12626. }
  12627. declare module BABYLON {
  12628. /**
  12629. * Particle emitter emitting particles from a point.
  12630. * It emits the particles randomly between 2 given directions.
  12631. */
  12632. export class PointParticleEmitter implements IParticleEmitterType {
  12633. /**
  12634. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12635. */
  12636. direction1: Vector3;
  12637. /**
  12638. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12639. */
  12640. direction2: Vector3;
  12641. /**
  12642. * Creates a new instance PointParticleEmitter
  12643. */
  12644. constructor();
  12645. /**
  12646. * Called by the particle System when the direction is computed for the created particle.
  12647. * @param worldMatrix is the world matrix of the particle system
  12648. * @param directionToUpdate is the direction vector to update with the result
  12649. * @param particle is the particle we are computed the direction for
  12650. * @param isLocal defines if the direction should be set in local space
  12651. */
  12652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12653. /**
  12654. * Called by the particle System when the position is computed for the created particle.
  12655. * @param worldMatrix is the world matrix of the particle system
  12656. * @param positionToUpdate is the position vector to update with the result
  12657. * @param particle is the particle we are computed the position for
  12658. * @param isLocal defines if the position should be set in local space
  12659. */
  12660. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12661. /**
  12662. * Clones the current emitter and returns a copy of it
  12663. * @returns the new emitter
  12664. */
  12665. clone(): PointParticleEmitter;
  12666. /**
  12667. * Called by the GPUParticleSystem to setup the update shader
  12668. * @param effect defines the update shader
  12669. */
  12670. applyToShader(effect: Effect): void;
  12671. /**
  12672. * Returns a string to use to update the GPU particles update shader
  12673. * @returns a string containng the defines string
  12674. */
  12675. getEffectDefines(): string;
  12676. /**
  12677. * Returns the string "PointParticleEmitter"
  12678. * @returns a string containing the class name
  12679. */
  12680. getClassName(): string;
  12681. /**
  12682. * Serializes the particle system to a JSON object.
  12683. * @returns the JSON object
  12684. */
  12685. serialize(): any;
  12686. /**
  12687. * Parse properties from a JSON object
  12688. * @param serializationObject defines the JSON object
  12689. */
  12690. parse(serializationObject: any): void;
  12691. }
  12692. }
  12693. declare module BABYLON {
  12694. /**
  12695. * Particle emitter emitting particles from the inside of a sphere.
  12696. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12697. */
  12698. export class SphereParticleEmitter implements IParticleEmitterType {
  12699. /**
  12700. * The radius of the emission sphere.
  12701. */
  12702. radius: number;
  12703. /**
  12704. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12705. */
  12706. radiusRange: number;
  12707. /**
  12708. * How much to randomize the particle direction [0-1].
  12709. */
  12710. directionRandomizer: number;
  12711. /**
  12712. * Creates a new instance SphereParticleEmitter
  12713. * @param radius the radius of the emission sphere (1 by default)
  12714. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12715. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12716. */
  12717. constructor(
  12718. /**
  12719. * The radius of the emission sphere.
  12720. */
  12721. radius?: number,
  12722. /**
  12723. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12724. */
  12725. radiusRange?: number,
  12726. /**
  12727. * How much to randomize the particle direction [0-1].
  12728. */
  12729. directionRandomizer?: number);
  12730. /**
  12731. * Called by the particle System when the direction is computed for the created particle.
  12732. * @param worldMatrix is the world matrix of the particle system
  12733. * @param directionToUpdate is the direction vector to update with the result
  12734. * @param particle is the particle we are computed the direction for
  12735. * @param isLocal defines if the direction should be set in local space
  12736. */
  12737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12738. /**
  12739. * Called by the particle System when the position is computed for the created particle.
  12740. * @param worldMatrix is the world matrix of the particle system
  12741. * @param positionToUpdate is the position vector to update with the result
  12742. * @param particle is the particle we are computed the position for
  12743. * @param isLocal defines if the position should be set in local space
  12744. */
  12745. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12746. /**
  12747. * Clones the current emitter and returns a copy of it
  12748. * @returns the new emitter
  12749. */
  12750. clone(): SphereParticleEmitter;
  12751. /**
  12752. * Called by the GPUParticleSystem to setup the update shader
  12753. * @param effect defines the update shader
  12754. */
  12755. applyToShader(effect: Effect): void;
  12756. /**
  12757. * Returns a string to use to update the GPU particles update shader
  12758. * @returns a string containng the defines string
  12759. */
  12760. getEffectDefines(): string;
  12761. /**
  12762. * Returns the string "SphereParticleEmitter"
  12763. * @returns a string containing the class name
  12764. */
  12765. getClassName(): string;
  12766. /**
  12767. * Serializes the particle system to a JSON object.
  12768. * @returns the JSON object
  12769. */
  12770. serialize(): any;
  12771. /**
  12772. * Parse properties from a JSON object
  12773. * @param serializationObject defines the JSON object
  12774. */
  12775. parse(serializationObject: any): void;
  12776. }
  12777. /**
  12778. * Particle emitter emitting particles from the inside of a sphere.
  12779. * It emits the particles randomly between two vectors.
  12780. */
  12781. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12782. /**
  12783. * The min limit of the emission direction.
  12784. */
  12785. direction1: Vector3;
  12786. /**
  12787. * The max limit of the emission direction.
  12788. */
  12789. direction2: Vector3;
  12790. /**
  12791. * Creates a new instance SphereDirectedParticleEmitter
  12792. * @param radius the radius of the emission sphere (1 by default)
  12793. * @param direction1 the min limit of the emission direction (up vector by default)
  12794. * @param direction2 the max limit of the emission direction (up vector by default)
  12795. */
  12796. constructor(radius?: number,
  12797. /**
  12798. * The min limit of the emission direction.
  12799. */
  12800. direction1?: Vector3,
  12801. /**
  12802. * The max limit of the emission direction.
  12803. */
  12804. direction2?: Vector3);
  12805. /**
  12806. * Called by the particle System when the direction is computed for the created particle.
  12807. * @param worldMatrix is the world matrix of the particle system
  12808. * @param directionToUpdate is the direction vector to update with the result
  12809. * @param particle is the particle we are computed the direction for
  12810. */
  12811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12812. /**
  12813. * Clones the current emitter and returns a copy of it
  12814. * @returns the new emitter
  12815. */
  12816. clone(): SphereDirectedParticleEmitter;
  12817. /**
  12818. * Called by the GPUParticleSystem to setup the update shader
  12819. * @param effect defines the update shader
  12820. */
  12821. applyToShader(effect: Effect): void;
  12822. /**
  12823. * Returns a string to use to update the GPU particles update shader
  12824. * @returns a string containng the defines string
  12825. */
  12826. getEffectDefines(): string;
  12827. /**
  12828. * Returns the string "SphereDirectedParticleEmitter"
  12829. * @returns a string containing the class name
  12830. */
  12831. getClassName(): string;
  12832. /**
  12833. * Serializes the particle system to a JSON object.
  12834. * @returns the JSON object
  12835. */
  12836. serialize(): any;
  12837. /**
  12838. * Parse properties from a JSON object
  12839. * @param serializationObject defines the JSON object
  12840. */
  12841. parse(serializationObject: any): void;
  12842. }
  12843. }
  12844. declare module BABYLON {
  12845. /**
  12846. * Particle emitter emitting particles from a custom list of positions.
  12847. */
  12848. export class CustomParticleEmitter implements IParticleEmitterType {
  12849. /**
  12850. * Gets or sets the position generator that will create the inital position of each particle.
  12851. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12852. */
  12853. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12854. /**
  12855. * Gets or sets the destination generator that will create the final destination of each particle.
  12856. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12857. */
  12858. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12859. /**
  12860. * Creates a new instance CustomParticleEmitter
  12861. */
  12862. constructor();
  12863. /**
  12864. * Called by the particle System when the direction is computed for the created particle.
  12865. * @param worldMatrix is the world matrix of the particle system
  12866. * @param directionToUpdate is the direction vector to update with the result
  12867. * @param particle is the particle we are computed the direction for
  12868. * @param isLocal defines if the direction should be set in local space
  12869. */
  12870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12871. /**
  12872. * Called by the particle System when the position is computed for the created particle.
  12873. * @param worldMatrix is the world matrix of the particle system
  12874. * @param positionToUpdate is the position vector to update with the result
  12875. * @param particle is the particle we are computed the position for
  12876. * @param isLocal defines if the position should be set in local space
  12877. */
  12878. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12879. /**
  12880. * Clones the current emitter and returns a copy of it
  12881. * @returns the new emitter
  12882. */
  12883. clone(): CustomParticleEmitter;
  12884. /**
  12885. * Called by the GPUParticleSystem to setup the update shader
  12886. * @param effect defines the update shader
  12887. */
  12888. applyToShader(effect: Effect): void;
  12889. /**
  12890. * Returns a string to use to update the GPU particles update shader
  12891. * @returns a string containng the defines string
  12892. */
  12893. getEffectDefines(): string;
  12894. /**
  12895. * Returns the string "PointParticleEmitter"
  12896. * @returns a string containing the class name
  12897. */
  12898. getClassName(): string;
  12899. /**
  12900. * Serializes the particle system to a JSON object.
  12901. * @returns the JSON object
  12902. */
  12903. serialize(): any;
  12904. /**
  12905. * Parse properties from a JSON object
  12906. * @param serializationObject defines the JSON object
  12907. */
  12908. parse(serializationObject: any): void;
  12909. }
  12910. }
  12911. declare module BABYLON {
  12912. /**
  12913. * Particle emitter emitting particles from the inside of a box.
  12914. * It emits the particles randomly between 2 given directions.
  12915. */
  12916. export class MeshParticleEmitter implements IParticleEmitterType {
  12917. private _indices;
  12918. private _positions;
  12919. private _normals;
  12920. private _storedNormal;
  12921. private _mesh;
  12922. /**
  12923. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12924. */
  12925. direction1: Vector3;
  12926. /**
  12927. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12928. */
  12929. direction2: Vector3;
  12930. /**
  12931. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12932. */
  12933. useMeshNormalsForDirection: boolean;
  12934. /** Defines the mesh to use as source */
  12935. get mesh(): Nullable<AbstractMesh>;
  12936. set mesh(value: Nullable<AbstractMesh>);
  12937. /**
  12938. * Creates a new instance MeshParticleEmitter
  12939. * @param mesh defines the mesh to use as source
  12940. */
  12941. constructor(mesh?: Nullable<AbstractMesh>);
  12942. /**
  12943. * Called by the particle System when the direction is computed for the created particle.
  12944. * @param worldMatrix is the world matrix of the particle system
  12945. * @param directionToUpdate is the direction vector to update with the result
  12946. * @param particle is the particle we are computed the direction for
  12947. * @param isLocal defines if the direction should be set in local space
  12948. */
  12949. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12950. /**
  12951. * Called by the particle System when the position is computed for the created particle.
  12952. * @param worldMatrix is the world matrix of the particle system
  12953. * @param positionToUpdate is the position vector to update with the result
  12954. * @param particle is the particle we are computed the position for
  12955. * @param isLocal defines if the position should be set in local space
  12956. */
  12957. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12958. /**
  12959. * Clones the current emitter and returns a copy of it
  12960. * @returns the new emitter
  12961. */
  12962. clone(): MeshParticleEmitter;
  12963. /**
  12964. * Called by the GPUParticleSystem to setup the update shader
  12965. * @param effect defines the update shader
  12966. */
  12967. applyToShader(effect: Effect): void;
  12968. /**
  12969. * Returns a string to use to update the GPU particles update shader
  12970. * @returns a string containng the defines string
  12971. */
  12972. getEffectDefines(): string;
  12973. /**
  12974. * Returns the string "BoxParticleEmitter"
  12975. * @returns a string containing the class name
  12976. */
  12977. getClassName(): string;
  12978. /**
  12979. * Serializes the particle system to a JSON object.
  12980. * @returns the JSON object
  12981. */
  12982. serialize(): any;
  12983. /**
  12984. * Parse properties from a JSON object
  12985. * @param serializationObject defines the JSON object
  12986. * @param scene defines the hosting scene
  12987. */
  12988. parse(serializationObject: any, scene: Scene): void;
  12989. }
  12990. }
  12991. declare module BABYLON {
  12992. /**
  12993. * Interface representing a particle system in Babylon.js.
  12994. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12995. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12996. */
  12997. export interface IParticleSystem {
  12998. /**
  12999. * List of animations used by the particle system.
  13000. */
  13001. animations: Animation[];
  13002. /**
  13003. * The id of the Particle system.
  13004. */
  13005. id: string;
  13006. /**
  13007. * The name of the Particle system.
  13008. */
  13009. name: string;
  13010. /**
  13011. * The emitter represents the Mesh or position we are attaching the particle system to.
  13012. */
  13013. emitter: Nullable<AbstractMesh | Vector3>;
  13014. /**
  13015. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13016. */
  13017. isBillboardBased: boolean;
  13018. /**
  13019. * The rendering group used by the Particle system to chose when to render.
  13020. */
  13021. renderingGroupId: number;
  13022. /**
  13023. * The layer mask we are rendering the particles through.
  13024. */
  13025. layerMask: number;
  13026. /**
  13027. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13028. */
  13029. updateSpeed: number;
  13030. /**
  13031. * The amount of time the particle system is running (depends of the overall update speed).
  13032. */
  13033. targetStopDuration: number;
  13034. /**
  13035. * The texture used to render each particle. (this can be a spritesheet)
  13036. */
  13037. particleTexture: Nullable<Texture>;
  13038. /**
  13039. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13040. */
  13041. blendMode: number;
  13042. /**
  13043. * Minimum life time of emitting particles.
  13044. */
  13045. minLifeTime: number;
  13046. /**
  13047. * Maximum life time of emitting particles.
  13048. */
  13049. maxLifeTime: number;
  13050. /**
  13051. * Minimum Size of emitting particles.
  13052. */
  13053. minSize: number;
  13054. /**
  13055. * Maximum Size of emitting particles.
  13056. */
  13057. maxSize: number;
  13058. /**
  13059. * Minimum scale of emitting particles on X axis.
  13060. */
  13061. minScaleX: number;
  13062. /**
  13063. * Maximum scale of emitting particles on X axis.
  13064. */
  13065. maxScaleX: number;
  13066. /**
  13067. * Minimum scale of emitting particles on Y axis.
  13068. */
  13069. minScaleY: number;
  13070. /**
  13071. * Maximum scale of emitting particles on Y axis.
  13072. */
  13073. maxScaleY: number;
  13074. /**
  13075. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13076. */
  13077. color1: Color4;
  13078. /**
  13079. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13080. */
  13081. color2: Color4;
  13082. /**
  13083. * Color the particle will have at the end of its lifetime.
  13084. */
  13085. colorDead: Color4;
  13086. /**
  13087. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13088. */
  13089. emitRate: number;
  13090. /**
  13091. * You can use gravity if you want to give an orientation to your particles.
  13092. */
  13093. gravity: Vector3;
  13094. /**
  13095. * Minimum power of emitting particles.
  13096. */
  13097. minEmitPower: number;
  13098. /**
  13099. * Maximum power of emitting particles.
  13100. */
  13101. maxEmitPower: number;
  13102. /**
  13103. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13104. */
  13105. minAngularSpeed: number;
  13106. /**
  13107. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13108. */
  13109. maxAngularSpeed: number;
  13110. /**
  13111. * Gets or sets the minimal initial rotation in radians.
  13112. */
  13113. minInitialRotation: number;
  13114. /**
  13115. * Gets or sets the maximal initial rotation in radians.
  13116. */
  13117. maxInitialRotation: number;
  13118. /**
  13119. * The particle emitter type defines the emitter used by the particle system.
  13120. * It can be for example box, sphere, or cone...
  13121. */
  13122. particleEmitterType: Nullable<IParticleEmitterType>;
  13123. /**
  13124. * Defines the delay in milliseconds before starting the system (0 by default)
  13125. */
  13126. startDelay: number;
  13127. /**
  13128. * 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
  13129. */
  13130. preWarmCycles: number;
  13131. /**
  13132. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13133. */
  13134. preWarmStepOffset: number;
  13135. /**
  13136. * 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)
  13137. */
  13138. spriteCellChangeSpeed: number;
  13139. /**
  13140. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13141. */
  13142. startSpriteCellID: number;
  13143. /**
  13144. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13145. */
  13146. endSpriteCellID: number;
  13147. /**
  13148. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13149. */
  13150. spriteCellWidth: number;
  13151. /**
  13152. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13153. */
  13154. spriteCellHeight: number;
  13155. /**
  13156. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13157. */
  13158. spriteRandomStartCell: boolean;
  13159. /**
  13160. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13161. */
  13162. isAnimationSheetEnabled: boolean;
  13163. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13164. translationPivot: Vector2;
  13165. /**
  13166. * Gets or sets a texture used to add random noise to particle positions
  13167. */
  13168. noiseTexture: Nullable<BaseTexture>;
  13169. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13170. noiseStrength: Vector3;
  13171. /**
  13172. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13173. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13174. */
  13175. billboardMode: number;
  13176. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13177. limitVelocityDamping: number;
  13178. /**
  13179. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13180. */
  13181. beginAnimationOnStart: boolean;
  13182. /**
  13183. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13184. */
  13185. beginAnimationFrom: number;
  13186. /**
  13187. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13188. */
  13189. beginAnimationTo: number;
  13190. /**
  13191. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13192. */
  13193. beginAnimationLoop: boolean;
  13194. /**
  13195. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13196. */
  13197. disposeOnStop: boolean;
  13198. /**
  13199. * Specifies if the particles are updated in emitter local space or world space
  13200. */
  13201. isLocal: boolean;
  13202. /**
  13203. * Gets the maximum number of particles active at the same time.
  13204. * @returns The max number of active particles.
  13205. */
  13206. getCapacity(): number;
  13207. /**
  13208. * Gets the number of particles active at the same time.
  13209. * @returns The number of active particles.
  13210. */
  13211. getActiveCount(): number;
  13212. /**
  13213. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13214. * @returns True if it has been started, otherwise false.
  13215. */
  13216. isStarted(): boolean;
  13217. /**
  13218. * Animates the particle system for this frame.
  13219. */
  13220. animate(): void;
  13221. /**
  13222. * Renders the particle system in its current state.
  13223. * @returns the current number of particles
  13224. */
  13225. render(): number;
  13226. /**
  13227. * Dispose the particle system and frees its associated resources.
  13228. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13229. */
  13230. dispose(disposeTexture?: boolean): void;
  13231. /**
  13232. * Clones the particle system.
  13233. * @param name The name of the cloned object
  13234. * @param newEmitter The new emitter to use
  13235. * @returns the cloned particle system
  13236. */
  13237. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13238. /**
  13239. * Serializes the particle system to a JSON object.
  13240. * @returns the JSON object
  13241. */
  13242. serialize(): any;
  13243. /**
  13244. * Rebuild the particle system
  13245. */
  13246. rebuild(): void;
  13247. /**
  13248. * Starts the particle system and begins to emit
  13249. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13250. */
  13251. start(delay?: number): void;
  13252. /**
  13253. * Stops the particle system.
  13254. */
  13255. stop(): void;
  13256. /**
  13257. * Remove all active particles
  13258. */
  13259. reset(): void;
  13260. /**
  13261. * Gets a boolean indicating that the system is stopping
  13262. * @returns true if the system is currently stopping
  13263. */
  13264. isStopping(): boolean;
  13265. /**
  13266. * Is this system ready to be used/rendered
  13267. * @return true if the system is ready
  13268. */
  13269. isReady(): boolean;
  13270. /**
  13271. * Returns the string "ParticleSystem"
  13272. * @returns a string containing the class name
  13273. */
  13274. getClassName(): string;
  13275. /**
  13276. * Adds a new color gradient
  13277. * @param gradient defines the gradient to use (between 0 and 1)
  13278. * @param color1 defines the color to affect to the specified gradient
  13279. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13280. * @returns the current particle system
  13281. */
  13282. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13283. /**
  13284. * Remove a specific color gradient
  13285. * @param gradient defines the gradient to remove
  13286. * @returns the current particle system
  13287. */
  13288. removeColorGradient(gradient: number): IParticleSystem;
  13289. /**
  13290. * Adds a new size gradient
  13291. * @param gradient defines the gradient to use (between 0 and 1)
  13292. * @param factor defines the size factor to affect to the specified gradient
  13293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13294. * @returns the current particle system
  13295. */
  13296. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13297. /**
  13298. * Remove a specific size gradient
  13299. * @param gradient defines the gradient to remove
  13300. * @returns the current particle system
  13301. */
  13302. removeSizeGradient(gradient: number): IParticleSystem;
  13303. /**
  13304. * Gets the current list of color gradients.
  13305. * You must use addColorGradient and removeColorGradient to udpate this list
  13306. * @returns the list of color gradients
  13307. */
  13308. getColorGradients(): Nullable<Array<ColorGradient>>;
  13309. /**
  13310. * Gets the current list of size gradients.
  13311. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13312. * @returns the list of size gradients
  13313. */
  13314. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13315. /**
  13316. * Gets the current list of angular speed gradients.
  13317. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13318. * @returns the list of angular speed gradients
  13319. */
  13320. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13321. /**
  13322. * Adds a new angular speed gradient
  13323. * @param gradient defines the gradient to use (between 0 and 1)
  13324. * @param factor defines the angular speed to affect to the specified gradient
  13325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13326. * @returns the current particle system
  13327. */
  13328. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13329. /**
  13330. * Remove a specific angular speed gradient
  13331. * @param gradient defines the gradient to remove
  13332. * @returns the current particle system
  13333. */
  13334. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13335. /**
  13336. * Gets the current list of velocity gradients.
  13337. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13338. * @returns the list of velocity gradients
  13339. */
  13340. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13341. /**
  13342. * Adds a new velocity gradient
  13343. * @param gradient defines the gradient to use (between 0 and 1)
  13344. * @param factor defines the velocity to affect to the specified gradient
  13345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13346. * @returns the current particle system
  13347. */
  13348. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13349. /**
  13350. * Remove a specific velocity gradient
  13351. * @param gradient defines the gradient to remove
  13352. * @returns the current particle system
  13353. */
  13354. removeVelocityGradient(gradient: number): IParticleSystem;
  13355. /**
  13356. * Gets the current list of limit velocity gradients.
  13357. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13358. * @returns the list of limit velocity gradients
  13359. */
  13360. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13361. /**
  13362. * Adds a new limit velocity gradient
  13363. * @param gradient defines the gradient to use (between 0 and 1)
  13364. * @param factor defines the limit velocity to affect to the specified gradient
  13365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13366. * @returns the current particle system
  13367. */
  13368. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13369. /**
  13370. * Remove a specific limit velocity gradient
  13371. * @param gradient defines the gradient to remove
  13372. * @returns the current particle system
  13373. */
  13374. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13375. /**
  13376. * Adds a new drag gradient
  13377. * @param gradient defines the gradient to use (between 0 and 1)
  13378. * @param factor defines the drag to affect to the specified gradient
  13379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13380. * @returns the current particle system
  13381. */
  13382. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13383. /**
  13384. * Remove a specific drag gradient
  13385. * @param gradient defines the gradient to remove
  13386. * @returns the current particle system
  13387. */
  13388. removeDragGradient(gradient: number): IParticleSystem;
  13389. /**
  13390. * Gets the current list of drag gradients.
  13391. * You must use addDragGradient and removeDragGradient to udpate this list
  13392. * @returns the list of drag gradients
  13393. */
  13394. getDragGradients(): Nullable<Array<FactorGradient>>;
  13395. /**
  13396. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13397. * @param gradient defines the gradient to use (between 0 and 1)
  13398. * @param factor defines the emit rate to affect to the specified gradient
  13399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13400. * @returns the current particle system
  13401. */
  13402. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13403. /**
  13404. * Remove a specific emit rate gradient
  13405. * @param gradient defines the gradient to remove
  13406. * @returns the current particle system
  13407. */
  13408. removeEmitRateGradient(gradient: number): IParticleSystem;
  13409. /**
  13410. * Gets the current list of emit rate gradients.
  13411. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13412. * @returns the list of emit rate gradients
  13413. */
  13414. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13415. /**
  13416. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13417. * @param gradient defines the gradient to use (between 0 and 1)
  13418. * @param factor defines the start size to affect to the specified gradient
  13419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13420. * @returns the current particle system
  13421. */
  13422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13423. /**
  13424. * Remove a specific start size gradient
  13425. * @param gradient defines the gradient to remove
  13426. * @returns the current particle system
  13427. */
  13428. removeStartSizeGradient(gradient: number): IParticleSystem;
  13429. /**
  13430. * Gets the current list of start size gradients.
  13431. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13432. * @returns the list of start size gradients
  13433. */
  13434. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13435. /**
  13436. * Adds a new life time gradient
  13437. * @param gradient defines the gradient to use (between 0 and 1)
  13438. * @param factor defines the life time factor to affect to the specified gradient
  13439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13440. * @returns the current particle system
  13441. */
  13442. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13443. /**
  13444. * Remove a specific life time gradient
  13445. * @param gradient defines the gradient to remove
  13446. * @returns the current particle system
  13447. */
  13448. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13449. /**
  13450. * Gets the current list of life time gradients.
  13451. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13452. * @returns the list of life time gradients
  13453. */
  13454. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13455. /**
  13456. * Gets the current list of color gradients.
  13457. * You must use addColorGradient and removeColorGradient to udpate this list
  13458. * @returns the list of color gradients
  13459. */
  13460. getColorGradients(): Nullable<Array<ColorGradient>>;
  13461. /**
  13462. * Adds a new ramp gradient used to remap particle colors
  13463. * @param gradient defines the gradient to use (between 0 and 1)
  13464. * @param color defines the color to affect to the specified gradient
  13465. * @returns the current particle system
  13466. */
  13467. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13468. /**
  13469. * Gets the current list of ramp gradients.
  13470. * You must use addRampGradient and removeRampGradient to udpate this list
  13471. * @returns the list of ramp gradients
  13472. */
  13473. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13474. /** Gets or sets a boolean indicating that ramp gradients must be used
  13475. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13476. */
  13477. useRampGradients: boolean;
  13478. /**
  13479. * Adds a new color remap gradient
  13480. * @param gradient defines the gradient to use (between 0 and 1)
  13481. * @param min defines the color remap minimal range
  13482. * @param max defines the color remap maximal range
  13483. * @returns the current particle system
  13484. */
  13485. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13486. /**
  13487. * Gets the current list of color remap gradients.
  13488. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13489. * @returns the list of color remap gradients
  13490. */
  13491. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13492. /**
  13493. * Adds a new alpha remap gradient
  13494. * @param gradient defines the gradient to use (between 0 and 1)
  13495. * @param min defines the alpha remap minimal range
  13496. * @param max defines the alpha remap maximal range
  13497. * @returns the current particle system
  13498. */
  13499. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13500. /**
  13501. * Gets the current list of alpha remap gradients.
  13502. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13503. * @returns the list of alpha remap gradients
  13504. */
  13505. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13506. /**
  13507. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13508. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13509. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13510. * @returns the emitter
  13511. */
  13512. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13513. /**
  13514. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13515. * @param radius The radius of the hemisphere to emit from
  13516. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13517. * @returns the emitter
  13518. */
  13519. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13520. /**
  13521. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13522. * @param radius The radius of the sphere to emit from
  13523. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13524. * @returns the emitter
  13525. */
  13526. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13527. /**
  13528. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13529. * @param radius The radius of the sphere to emit from
  13530. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13531. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13532. * @returns the emitter
  13533. */
  13534. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13535. /**
  13536. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13537. * @param radius The radius of the emission cylinder
  13538. * @param height The height of the emission cylinder
  13539. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13540. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13541. * @returns the emitter
  13542. */
  13543. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13544. /**
  13545. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13546. * @param radius The radius of the cylinder to emit from
  13547. * @param height The height of the emission cylinder
  13548. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13551. * @returns the emitter
  13552. */
  13553. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13554. /**
  13555. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13556. * @param radius The radius of the cone to emit from
  13557. * @param angle The base angle of the cone
  13558. * @returns the emitter
  13559. */
  13560. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13561. /**
  13562. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13565. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13566. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13567. * @returns the emitter
  13568. */
  13569. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13570. /**
  13571. * Get hosting scene
  13572. * @returns the scene
  13573. */
  13574. getScene(): Scene;
  13575. }
  13576. }
  13577. declare module BABYLON {
  13578. /**
  13579. * 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.
  13580. * @see https://doc.babylonjs.com/how_to/transformnode
  13581. */
  13582. export class TransformNode extends Node {
  13583. /**
  13584. * Object will not rotate to face the camera
  13585. */
  13586. static BILLBOARDMODE_NONE: number;
  13587. /**
  13588. * Object will rotate to face the camera but only on the x axis
  13589. */
  13590. static BILLBOARDMODE_X: number;
  13591. /**
  13592. * Object will rotate to face the camera but only on the y axis
  13593. */
  13594. static BILLBOARDMODE_Y: number;
  13595. /**
  13596. * Object will rotate to face the camera but only on the z axis
  13597. */
  13598. static BILLBOARDMODE_Z: number;
  13599. /**
  13600. * Object will rotate to face the camera
  13601. */
  13602. static BILLBOARDMODE_ALL: number;
  13603. /**
  13604. * Object will rotate to face the camera's position instead of orientation
  13605. */
  13606. static BILLBOARDMODE_USE_POSITION: number;
  13607. private _forward;
  13608. private _forwardInverted;
  13609. private _up;
  13610. private _right;
  13611. private _rightInverted;
  13612. private _position;
  13613. private _rotation;
  13614. private _rotationQuaternion;
  13615. protected _scaling: Vector3;
  13616. protected _isDirty: boolean;
  13617. private _transformToBoneReferal;
  13618. private _isAbsoluteSynced;
  13619. private _billboardMode;
  13620. /**
  13621. * Gets or sets the billboard mode. Default is 0.
  13622. *
  13623. * | Value | Type | Description |
  13624. * | --- | --- | --- |
  13625. * | 0 | BILLBOARDMODE_NONE | |
  13626. * | 1 | BILLBOARDMODE_X | |
  13627. * | 2 | BILLBOARDMODE_Y | |
  13628. * | 4 | BILLBOARDMODE_Z | |
  13629. * | 7 | BILLBOARDMODE_ALL | |
  13630. *
  13631. */
  13632. get billboardMode(): number;
  13633. set billboardMode(value: number);
  13634. private _preserveParentRotationForBillboard;
  13635. /**
  13636. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13637. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13638. */
  13639. get preserveParentRotationForBillboard(): boolean;
  13640. set preserveParentRotationForBillboard(value: boolean);
  13641. /**
  13642. * 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
  13643. */
  13644. scalingDeterminant: number;
  13645. private _infiniteDistance;
  13646. /**
  13647. * Gets or sets the distance of the object to max, often used by skybox
  13648. */
  13649. get infiniteDistance(): boolean;
  13650. set infiniteDistance(value: boolean);
  13651. /**
  13652. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13653. * By default the system will update normals to compensate
  13654. */
  13655. ignoreNonUniformScaling: boolean;
  13656. /**
  13657. * 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
  13658. */
  13659. reIntegrateRotationIntoRotationQuaternion: boolean;
  13660. /** @hidden */
  13661. _poseMatrix: Nullable<Matrix>;
  13662. /** @hidden */
  13663. _localMatrix: Matrix;
  13664. private _usePivotMatrix;
  13665. private _absolutePosition;
  13666. private _absoluteScaling;
  13667. private _absoluteRotationQuaternion;
  13668. private _pivotMatrix;
  13669. private _pivotMatrixInverse;
  13670. protected _postMultiplyPivotMatrix: boolean;
  13671. protected _isWorldMatrixFrozen: boolean;
  13672. /** @hidden */
  13673. _indexInSceneTransformNodesArray: number;
  13674. /**
  13675. * An event triggered after the world matrix is updated
  13676. */
  13677. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13678. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13679. /**
  13680. * Gets a string identifying the name of the class
  13681. * @returns "TransformNode" string
  13682. */
  13683. getClassName(): string;
  13684. /**
  13685. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13686. */
  13687. get position(): Vector3;
  13688. set position(newPosition: Vector3);
  13689. /**
  13690. * 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)).
  13691. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13692. */
  13693. get rotation(): Vector3;
  13694. set rotation(newRotation: Vector3);
  13695. /**
  13696. * 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)).
  13697. */
  13698. get scaling(): Vector3;
  13699. set scaling(newScaling: Vector3);
  13700. /**
  13701. * 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).
  13702. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13703. */
  13704. get rotationQuaternion(): Nullable<Quaternion>;
  13705. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13706. /**
  13707. * The forward direction of that transform in world space.
  13708. */
  13709. get forward(): Vector3;
  13710. /**
  13711. * The up direction of that transform in world space.
  13712. */
  13713. get up(): Vector3;
  13714. /**
  13715. * The right direction of that transform in world space.
  13716. */
  13717. get right(): Vector3;
  13718. /**
  13719. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13720. * @param matrix the matrix to copy the pose from
  13721. * @returns this TransformNode.
  13722. */
  13723. updatePoseMatrix(matrix: Matrix): TransformNode;
  13724. /**
  13725. * Returns the mesh Pose matrix.
  13726. * @returns the pose matrix
  13727. */
  13728. getPoseMatrix(): Matrix;
  13729. /** @hidden */
  13730. _isSynchronized(): boolean;
  13731. /** @hidden */
  13732. _initCache(): void;
  13733. /**
  13734. * Flag the transform node as dirty (Forcing it to update everything)
  13735. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13736. * @returns this transform node
  13737. */
  13738. markAsDirty(property: string): TransformNode;
  13739. /**
  13740. * Returns the current mesh absolute position.
  13741. * Returns a Vector3.
  13742. */
  13743. get absolutePosition(): Vector3;
  13744. /**
  13745. * Returns the current mesh absolute scaling.
  13746. * Returns a Vector3.
  13747. */
  13748. get absoluteScaling(): Vector3;
  13749. /**
  13750. * Returns the current mesh absolute rotation.
  13751. * Returns a Quaternion.
  13752. */
  13753. get absoluteRotationQuaternion(): Quaternion;
  13754. /**
  13755. * Sets a new matrix to apply before all other transformation
  13756. * @param matrix defines the transform matrix
  13757. * @returns the current TransformNode
  13758. */
  13759. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13760. /**
  13761. * Sets a new pivot matrix to the current node
  13762. * @param matrix defines the new pivot matrix to use
  13763. * @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
  13764. * @returns the current TransformNode
  13765. */
  13766. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13767. /**
  13768. * Returns the mesh pivot matrix.
  13769. * Default : Identity.
  13770. * @returns the matrix
  13771. */
  13772. getPivotMatrix(): Matrix;
  13773. /**
  13774. * Instantiate (when possible) or clone that node with its hierarchy
  13775. * @param newParent defines the new parent to use for the instance (or clone)
  13776. * @param options defines options to configure how copy is done
  13777. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13778. * @returns an instance (or a clone) of the current node with its hiearchy
  13779. */
  13780. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13781. doNotInstantiate: boolean;
  13782. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13783. /**
  13784. * Prevents the World matrix to be computed any longer
  13785. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13786. * @returns the TransformNode.
  13787. */
  13788. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13789. /**
  13790. * Allows back the World matrix computation.
  13791. * @returns the TransformNode.
  13792. */
  13793. unfreezeWorldMatrix(): this;
  13794. /**
  13795. * True if the World matrix has been frozen.
  13796. */
  13797. get isWorldMatrixFrozen(): boolean;
  13798. /**
  13799. * Retuns the mesh absolute position in the World.
  13800. * @returns a Vector3.
  13801. */
  13802. getAbsolutePosition(): Vector3;
  13803. /**
  13804. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13805. * @param absolutePosition the absolute position to set
  13806. * @returns the TransformNode.
  13807. */
  13808. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13809. /**
  13810. * Sets the mesh position in its local space.
  13811. * @param vector3 the position to set in localspace
  13812. * @returns the TransformNode.
  13813. */
  13814. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13815. /**
  13816. * Returns the mesh position in the local space from the current World matrix values.
  13817. * @returns a new Vector3.
  13818. */
  13819. getPositionExpressedInLocalSpace(): Vector3;
  13820. /**
  13821. * Translates the mesh along the passed Vector3 in its local space.
  13822. * @param vector3 the distance to translate in localspace
  13823. * @returns the TransformNode.
  13824. */
  13825. locallyTranslate(vector3: Vector3): TransformNode;
  13826. private static _lookAtVectorCache;
  13827. /**
  13828. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13829. * @param targetPoint the position (must be in same space as current mesh) to look at
  13830. * @param yawCor optional yaw (y-axis) correction in radians
  13831. * @param pitchCor optional pitch (x-axis) correction in radians
  13832. * @param rollCor optional roll (z-axis) correction in radians
  13833. * @param space the choosen space of the target
  13834. * @returns the TransformNode.
  13835. */
  13836. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13837. /**
  13838. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13839. * This Vector3 is expressed in the World space.
  13840. * @param localAxis axis to rotate
  13841. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13842. */
  13843. getDirection(localAxis: Vector3): Vector3;
  13844. /**
  13845. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13846. * localAxis is expressed in the mesh local space.
  13847. * result is computed in the Wordl space from the mesh World matrix.
  13848. * @param localAxis axis to rotate
  13849. * @param result the resulting transformnode
  13850. * @returns this TransformNode.
  13851. */
  13852. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13853. /**
  13854. * Sets this transform node rotation to the given local axis.
  13855. * @param localAxis the axis in local space
  13856. * @param yawCor optional yaw (y-axis) correction in radians
  13857. * @param pitchCor optional pitch (x-axis) correction in radians
  13858. * @param rollCor optional roll (z-axis) correction in radians
  13859. * @returns this TransformNode
  13860. */
  13861. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13862. /**
  13863. * Sets a new pivot point to the current node
  13864. * @param point defines the new pivot point to use
  13865. * @param space defines if the point is in world or local space (local by default)
  13866. * @returns the current TransformNode
  13867. */
  13868. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13869. /**
  13870. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13871. * @returns the pivot point
  13872. */
  13873. getPivotPoint(): Vector3;
  13874. /**
  13875. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13876. * @param result the vector3 to store the result
  13877. * @returns this TransformNode.
  13878. */
  13879. getPivotPointToRef(result: Vector3): TransformNode;
  13880. /**
  13881. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13882. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13883. */
  13884. getAbsolutePivotPoint(): Vector3;
  13885. /**
  13886. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13887. * @param result vector3 to store the result
  13888. * @returns this TransformNode.
  13889. */
  13890. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13891. /**
  13892. * Defines the passed node as the parent of the current node.
  13893. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13894. * @see https://doc.babylonjs.com/how_to/parenting
  13895. * @param node the node ot set as the parent
  13896. * @returns this TransformNode.
  13897. */
  13898. setParent(node: Nullable<Node>): TransformNode;
  13899. private _nonUniformScaling;
  13900. /**
  13901. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13902. */
  13903. get nonUniformScaling(): boolean;
  13904. /** @hidden */
  13905. _updateNonUniformScalingState(value: boolean): boolean;
  13906. /**
  13907. * Attach the current TransformNode to another TransformNode associated with a bone
  13908. * @param bone Bone affecting the TransformNode
  13909. * @param affectedTransformNode TransformNode associated with the bone
  13910. * @returns this object
  13911. */
  13912. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13913. /**
  13914. * Detach the transform node if its associated with a bone
  13915. * @returns this object
  13916. */
  13917. detachFromBone(): TransformNode;
  13918. private static _rotationAxisCache;
  13919. /**
  13920. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13921. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13922. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13923. * The passed axis is also normalized.
  13924. * @param axis the axis to rotate around
  13925. * @param amount the amount to rotate in radians
  13926. * @param space Space to rotate in (Default: local)
  13927. * @returns the TransformNode.
  13928. */
  13929. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13930. /**
  13931. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13932. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13933. * The passed axis is also normalized. .
  13934. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13935. * @param point the point to rotate around
  13936. * @param axis the axis to rotate around
  13937. * @param amount the amount to rotate in radians
  13938. * @returns the TransformNode
  13939. */
  13940. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13941. /**
  13942. * Translates the mesh along the axis vector for the passed distance in the given space.
  13943. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13944. * @param axis the axis to translate in
  13945. * @param distance the distance to translate
  13946. * @param space Space to rotate in (Default: local)
  13947. * @returns the TransformNode.
  13948. */
  13949. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13950. /**
  13951. * Adds a rotation step to the mesh current rotation.
  13952. * x, y, z are Euler angles expressed in radians.
  13953. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13954. * This means this rotation is made in the mesh local space only.
  13955. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13956. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13957. * ```javascript
  13958. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13959. * ```
  13960. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13961. * 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.
  13962. * @param x Rotation to add
  13963. * @param y Rotation to add
  13964. * @param z Rotation to add
  13965. * @returns the TransformNode.
  13966. */
  13967. addRotation(x: number, y: number, z: number): TransformNode;
  13968. /**
  13969. * @hidden
  13970. */
  13971. protected _getEffectiveParent(): Nullable<Node>;
  13972. /**
  13973. * Computes the world matrix of the node
  13974. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13975. * @returns the world matrix
  13976. */
  13977. computeWorldMatrix(force?: boolean): Matrix;
  13978. /**
  13979. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13980. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13981. */
  13982. resetLocalMatrix(independentOfChildren?: boolean): void;
  13983. protected _afterComputeWorldMatrix(): void;
  13984. /**
  13985. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13986. * @param func callback function to add
  13987. *
  13988. * @returns the TransformNode.
  13989. */
  13990. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13991. /**
  13992. * Removes a registered callback function.
  13993. * @param func callback function to remove
  13994. * @returns the TransformNode.
  13995. */
  13996. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13997. /**
  13998. * Gets the position of the current mesh in camera space
  13999. * @param camera defines the camera to use
  14000. * @returns a position
  14001. */
  14002. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14003. /**
  14004. * Returns the distance from the mesh to the active camera
  14005. * @param camera defines the camera to use
  14006. * @returns the distance
  14007. */
  14008. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14009. /**
  14010. * Clone the current transform node
  14011. * @param name Name of the new clone
  14012. * @param newParent New parent for the clone
  14013. * @param doNotCloneChildren Do not clone children hierarchy
  14014. * @returns the new transform node
  14015. */
  14016. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14017. /**
  14018. * Serializes the objects information.
  14019. * @param currentSerializationObject defines the object to serialize in
  14020. * @returns the serialized object
  14021. */
  14022. serialize(currentSerializationObject?: any): any;
  14023. /**
  14024. * Returns a new TransformNode object parsed from the source provided.
  14025. * @param parsedTransformNode is the source.
  14026. * @param scene the scne the object belongs to
  14027. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14028. * @returns a new TransformNode object parsed from the source provided.
  14029. */
  14030. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14031. /**
  14032. * Get all child-transformNodes of this node
  14033. * @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
  14034. * @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
  14035. * @returns an array of TransformNode
  14036. */
  14037. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14038. /**
  14039. * Releases resources associated with this transform node.
  14040. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14041. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14042. */
  14043. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14044. /**
  14045. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14046. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14047. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14048. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14049. * @returns the current mesh
  14050. */
  14051. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14052. private _syncAbsoluteScalingAndRotation;
  14053. }
  14054. }
  14055. declare module BABYLON {
  14056. /**
  14057. * Class used to override all child animations of a given target
  14058. */
  14059. export class AnimationPropertiesOverride {
  14060. /**
  14061. * Gets or sets a value indicating if animation blending must be used
  14062. */
  14063. enableBlending: boolean;
  14064. /**
  14065. * Gets or sets the blending speed to use when enableBlending is true
  14066. */
  14067. blendingSpeed: number;
  14068. /**
  14069. * Gets or sets the default loop mode to use
  14070. */
  14071. loopMode: number;
  14072. }
  14073. }
  14074. declare module BABYLON {
  14075. /**
  14076. * Class used to store bone information
  14077. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14078. */
  14079. export class Bone extends Node {
  14080. /**
  14081. * defines the bone name
  14082. */
  14083. name: string;
  14084. private static _tmpVecs;
  14085. private static _tmpQuat;
  14086. private static _tmpMats;
  14087. /**
  14088. * Gets the list of child bones
  14089. */
  14090. children: Bone[];
  14091. /** Gets the animations associated with this bone */
  14092. animations: Animation[];
  14093. /**
  14094. * Gets or sets bone length
  14095. */
  14096. length: number;
  14097. /**
  14098. * @hidden Internal only
  14099. * Set this value to map this bone to a different index in the transform matrices
  14100. * Set this value to -1 to exclude the bone from the transform matrices
  14101. */
  14102. _index: Nullable<number>;
  14103. private _skeleton;
  14104. private _localMatrix;
  14105. private _restPose;
  14106. private _baseMatrix;
  14107. private _absoluteTransform;
  14108. private _invertedAbsoluteTransform;
  14109. private _parent;
  14110. private _scalingDeterminant;
  14111. private _worldTransform;
  14112. private _localScaling;
  14113. private _localRotation;
  14114. private _localPosition;
  14115. private _needToDecompose;
  14116. private _needToCompose;
  14117. /** @hidden */
  14118. _linkedTransformNode: Nullable<TransformNode>;
  14119. /** @hidden */
  14120. _waitingTransformNodeId: Nullable<string>;
  14121. /** @hidden */
  14122. get _matrix(): Matrix;
  14123. /** @hidden */
  14124. set _matrix(value: Matrix);
  14125. /**
  14126. * Create a new bone
  14127. * @param name defines the bone name
  14128. * @param skeleton defines the parent skeleton
  14129. * @param parentBone defines the parent (can be null if the bone is the root)
  14130. * @param localMatrix defines the local matrix
  14131. * @param restPose defines the rest pose matrix
  14132. * @param baseMatrix defines the base matrix
  14133. * @param index defines index of the bone in the hiearchy
  14134. */
  14135. constructor(
  14136. /**
  14137. * defines the bone name
  14138. */
  14139. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14140. /**
  14141. * Gets the current object class name.
  14142. * @return the class name
  14143. */
  14144. getClassName(): string;
  14145. /**
  14146. * Gets the parent skeleton
  14147. * @returns a skeleton
  14148. */
  14149. getSkeleton(): Skeleton;
  14150. /**
  14151. * Gets parent bone
  14152. * @returns a bone or null if the bone is the root of the bone hierarchy
  14153. */
  14154. getParent(): Nullable<Bone>;
  14155. /**
  14156. * Returns an array containing the root bones
  14157. * @returns an array containing the root bones
  14158. */
  14159. getChildren(): Array<Bone>;
  14160. /**
  14161. * Gets the node index in matrix array generated for rendering
  14162. * @returns the node index
  14163. */
  14164. getIndex(): number;
  14165. /**
  14166. * Sets the parent bone
  14167. * @param parent defines the parent (can be null if the bone is the root)
  14168. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14169. */
  14170. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14171. /**
  14172. * Gets the local matrix
  14173. * @returns a matrix
  14174. */
  14175. getLocalMatrix(): Matrix;
  14176. /**
  14177. * Gets the base matrix (initial matrix which remains unchanged)
  14178. * @returns a matrix
  14179. */
  14180. getBaseMatrix(): Matrix;
  14181. /**
  14182. * Gets the rest pose matrix
  14183. * @returns a matrix
  14184. */
  14185. getRestPose(): Matrix;
  14186. /**
  14187. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14188. */
  14189. getWorldMatrix(): Matrix;
  14190. /**
  14191. * Sets the local matrix to rest pose matrix
  14192. */
  14193. returnToRest(): void;
  14194. /**
  14195. * Gets the inverse of the absolute transform matrix.
  14196. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14197. * @returns a matrix
  14198. */
  14199. getInvertedAbsoluteTransform(): Matrix;
  14200. /**
  14201. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14202. * @returns a matrix
  14203. */
  14204. getAbsoluteTransform(): Matrix;
  14205. /**
  14206. * Links with the given transform node.
  14207. * The local matrix of this bone is copied from the transform node every frame.
  14208. * @param transformNode defines the transform node to link to
  14209. */
  14210. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14211. /**
  14212. * Gets the node used to drive the bone's transformation
  14213. * @returns a transform node or null
  14214. */
  14215. getTransformNode(): Nullable<TransformNode>;
  14216. /** Gets or sets current position (in local space) */
  14217. get position(): Vector3;
  14218. set position(newPosition: Vector3);
  14219. /** Gets or sets current rotation (in local space) */
  14220. get rotation(): Vector3;
  14221. set rotation(newRotation: Vector3);
  14222. /** Gets or sets current rotation quaternion (in local space) */
  14223. get rotationQuaternion(): Quaternion;
  14224. set rotationQuaternion(newRotation: Quaternion);
  14225. /** Gets or sets current scaling (in local space) */
  14226. get scaling(): Vector3;
  14227. set scaling(newScaling: Vector3);
  14228. /**
  14229. * Gets the animation properties override
  14230. */
  14231. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14232. private _decompose;
  14233. private _compose;
  14234. /**
  14235. * Update the base and local matrices
  14236. * @param matrix defines the new base or local matrix
  14237. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14238. * @param updateLocalMatrix defines if the local matrix should be updated
  14239. */
  14240. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14241. /** @hidden */
  14242. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14243. /**
  14244. * Flag the bone as dirty (Forcing it to update everything)
  14245. */
  14246. markAsDirty(): void;
  14247. /** @hidden */
  14248. _markAsDirtyAndCompose(): void;
  14249. private _markAsDirtyAndDecompose;
  14250. /**
  14251. * Translate the bone in local or world space
  14252. * @param vec The amount to translate the bone
  14253. * @param space The space that the translation is in
  14254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14255. */
  14256. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14257. /**
  14258. * Set the postion of the bone in local or world space
  14259. * @param position The position to set the bone
  14260. * @param space The space that the position is in
  14261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14262. */
  14263. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14264. /**
  14265. * Set the absolute position of the bone (world space)
  14266. * @param position The position to set the bone
  14267. * @param mesh The mesh that this bone is attached to
  14268. */
  14269. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14270. /**
  14271. * Scale the bone on the x, y and z axes (in local space)
  14272. * @param x The amount to scale the bone on the x axis
  14273. * @param y The amount to scale the bone on the y axis
  14274. * @param z The amount to scale the bone on the z axis
  14275. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14276. */
  14277. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14278. /**
  14279. * Set the bone scaling in local space
  14280. * @param scale defines the scaling vector
  14281. */
  14282. setScale(scale: Vector3): void;
  14283. /**
  14284. * Gets the current scaling in local space
  14285. * @returns the current scaling vector
  14286. */
  14287. getScale(): Vector3;
  14288. /**
  14289. * Gets the current scaling in local space and stores it in a target vector
  14290. * @param result defines the target vector
  14291. */
  14292. getScaleToRef(result: Vector3): void;
  14293. /**
  14294. * Set the yaw, pitch, and roll of the bone in local or world space
  14295. * @param yaw The rotation of the bone on the y axis
  14296. * @param pitch The rotation of the bone on the x axis
  14297. * @param roll The rotation of the bone on the z axis
  14298. * @param space The space that the axes of rotation are in
  14299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14300. */
  14301. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14302. /**
  14303. * Add a rotation to the bone on an axis in local or world space
  14304. * @param axis The axis to rotate the bone on
  14305. * @param amount The amount to rotate the bone
  14306. * @param space The space that the axis is in
  14307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14308. */
  14309. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14310. /**
  14311. * Set the rotation of the bone to a particular axis angle in local or world space
  14312. * @param axis The axis to rotate the bone on
  14313. * @param angle The angle that the bone should be rotated to
  14314. * @param space The space that the axis is in
  14315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14316. */
  14317. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14318. /**
  14319. * Set the euler rotation of the bone in local of world space
  14320. * @param rotation The euler rotation that the bone should be set to
  14321. * @param space The space that the rotation is in
  14322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14323. */
  14324. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14325. /**
  14326. * Set the quaternion rotation of the bone in local of world space
  14327. * @param quat The quaternion rotation that the bone should be set to
  14328. * @param space The space that the rotation is in
  14329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14330. */
  14331. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14332. /**
  14333. * Set the rotation matrix of the bone in local of world space
  14334. * @param rotMat The rotation matrix that the bone should be set to
  14335. * @param space The space that the rotation is in
  14336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14337. */
  14338. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14339. private _rotateWithMatrix;
  14340. private _getNegativeRotationToRef;
  14341. /**
  14342. * Get the position of the bone in local or world space
  14343. * @param space The space that the returned position is in
  14344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14345. * @returns The position of the bone
  14346. */
  14347. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14348. /**
  14349. * Copy the position of the bone to a vector3 in local or world space
  14350. * @param space The space that the returned position is in
  14351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14352. * @param result The vector3 to copy the position to
  14353. */
  14354. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14355. /**
  14356. * Get the absolute position of the bone (world space)
  14357. * @param mesh The mesh that this bone is attached to
  14358. * @returns The absolute position of the bone
  14359. */
  14360. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14361. /**
  14362. * Copy the absolute position of the bone (world space) to the result param
  14363. * @param mesh The mesh that this bone is attached to
  14364. * @param result The vector3 to copy the absolute position to
  14365. */
  14366. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14367. /**
  14368. * Compute the absolute transforms of this bone and its children
  14369. */
  14370. computeAbsoluteTransforms(): void;
  14371. /**
  14372. * Get the world direction from an axis that is in the local space of the bone
  14373. * @param localAxis The local direction that is used to compute the world direction
  14374. * @param mesh The mesh that this bone is attached to
  14375. * @returns The world direction
  14376. */
  14377. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14378. /**
  14379. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14380. * @param localAxis The local direction that is used to compute the world direction
  14381. * @param mesh The mesh that this bone is attached to
  14382. * @param result The vector3 that the world direction will be copied to
  14383. */
  14384. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14385. /**
  14386. * Get the euler rotation of the bone in local or world space
  14387. * @param space The space that the rotation should be in
  14388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14389. * @returns The euler rotation
  14390. */
  14391. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14392. /**
  14393. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14394. * @param space The space that the rotation should be in
  14395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14396. * @param result The vector3 that the rotation should be copied to
  14397. */
  14398. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14399. /**
  14400. * Get the quaternion rotation of the bone in either local or world space
  14401. * @param space The space that the rotation should be in
  14402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14403. * @returns The quaternion rotation
  14404. */
  14405. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14406. /**
  14407. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14408. * @param space The space that the rotation should be in
  14409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14410. * @param result The quaternion that the rotation should be copied to
  14411. */
  14412. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14413. /**
  14414. * Get the rotation matrix of the bone in local or world space
  14415. * @param space The space that the rotation should be in
  14416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14417. * @returns The rotation matrix
  14418. */
  14419. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14420. /**
  14421. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14422. * @param space The space that the rotation should be in
  14423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14424. * @param result The quaternion that the rotation should be copied to
  14425. */
  14426. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14427. /**
  14428. * Get the world position of a point that is in the local space of the bone
  14429. * @param position The local position
  14430. * @param mesh The mesh that this bone is attached to
  14431. * @returns The world position
  14432. */
  14433. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14434. /**
  14435. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14436. * @param position The local position
  14437. * @param mesh The mesh that this bone is attached to
  14438. * @param result The vector3 that the world position should be copied to
  14439. */
  14440. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14441. /**
  14442. * Get the local position of a point that is in world space
  14443. * @param position The world position
  14444. * @param mesh The mesh that this bone is attached to
  14445. * @returns The local position
  14446. */
  14447. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14448. /**
  14449. * Get the local position of a point that is in world space and copy it to the result param
  14450. * @param position The world position
  14451. * @param mesh The mesh that this bone is attached to
  14452. * @param result The vector3 that the local position should be copied to
  14453. */
  14454. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14455. }
  14456. }
  14457. declare module BABYLON {
  14458. /**
  14459. * Defines a runtime animation
  14460. */
  14461. export class RuntimeAnimation {
  14462. private _events;
  14463. /**
  14464. * The current frame of the runtime animation
  14465. */
  14466. private _currentFrame;
  14467. /**
  14468. * The animation used by the runtime animation
  14469. */
  14470. private _animation;
  14471. /**
  14472. * The target of the runtime animation
  14473. */
  14474. private _target;
  14475. /**
  14476. * The initiating animatable
  14477. */
  14478. private _host;
  14479. /**
  14480. * The original value of the runtime animation
  14481. */
  14482. private _originalValue;
  14483. /**
  14484. * The original blend value of the runtime animation
  14485. */
  14486. private _originalBlendValue;
  14487. /**
  14488. * The offsets cache of the runtime animation
  14489. */
  14490. private _offsetsCache;
  14491. /**
  14492. * The high limits cache of the runtime animation
  14493. */
  14494. private _highLimitsCache;
  14495. /**
  14496. * Specifies if the runtime animation has been stopped
  14497. */
  14498. private _stopped;
  14499. /**
  14500. * The blending factor of the runtime animation
  14501. */
  14502. private _blendingFactor;
  14503. /**
  14504. * The BabylonJS scene
  14505. */
  14506. private _scene;
  14507. /**
  14508. * The current value of the runtime animation
  14509. */
  14510. private _currentValue;
  14511. /** @hidden */
  14512. _animationState: _IAnimationState;
  14513. /**
  14514. * The active target of the runtime animation
  14515. */
  14516. private _activeTargets;
  14517. private _currentActiveTarget;
  14518. private _directTarget;
  14519. /**
  14520. * The target path of the runtime animation
  14521. */
  14522. private _targetPath;
  14523. /**
  14524. * The weight of the runtime animation
  14525. */
  14526. private _weight;
  14527. /**
  14528. * The ratio offset of the runtime animation
  14529. */
  14530. private _ratioOffset;
  14531. /**
  14532. * The previous delay of the runtime animation
  14533. */
  14534. private _previousDelay;
  14535. /**
  14536. * The previous ratio of the runtime animation
  14537. */
  14538. private _previousRatio;
  14539. private _enableBlending;
  14540. private _keys;
  14541. private _minFrame;
  14542. private _maxFrame;
  14543. private _minValue;
  14544. private _maxValue;
  14545. private _targetIsArray;
  14546. /**
  14547. * Gets the current frame of the runtime animation
  14548. */
  14549. get currentFrame(): number;
  14550. /**
  14551. * Gets the weight of the runtime animation
  14552. */
  14553. get weight(): number;
  14554. /**
  14555. * Gets the current value of the runtime animation
  14556. */
  14557. get currentValue(): any;
  14558. /**
  14559. * Gets the target path of the runtime animation
  14560. */
  14561. get targetPath(): string;
  14562. /**
  14563. * Gets the actual target of the runtime animation
  14564. */
  14565. get target(): any;
  14566. /**
  14567. * Gets the additive state of the runtime animation
  14568. */
  14569. get isAdditive(): boolean;
  14570. /** @hidden */
  14571. _onLoop: () => void;
  14572. /**
  14573. * Create a new RuntimeAnimation object
  14574. * @param target defines the target of the animation
  14575. * @param animation defines the source animation object
  14576. * @param scene defines the hosting scene
  14577. * @param host defines the initiating Animatable
  14578. */
  14579. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14580. private _preparePath;
  14581. /**
  14582. * Gets the animation from the runtime animation
  14583. */
  14584. get animation(): Animation;
  14585. /**
  14586. * Resets the runtime animation to the beginning
  14587. * @param restoreOriginal defines whether to restore the target property to the original value
  14588. */
  14589. reset(restoreOriginal?: boolean): void;
  14590. /**
  14591. * Specifies if the runtime animation is stopped
  14592. * @returns Boolean specifying if the runtime animation is stopped
  14593. */
  14594. isStopped(): boolean;
  14595. /**
  14596. * Disposes of the runtime animation
  14597. */
  14598. dispose(): void;
  14599. /**
  14600. * Apply the interpolated value to the target
  14601. * @param currentValue defines the value computed by the animation
  14602. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14603. */
  14604. setValue(currentValue: any, weight: number): void;
  14605. private _getOriginalValues;
  14606. private _setValue;
  14607. /**
  14608. * Gets the loop pmode of the runtime animation
  14609. * @returns Loop Mode
  14610. */
  14611. private _getCorrectLoopMode;
  14612. /**
  14613. * Move the current animation to a given frame
  14614. * @param frame defines the frame to move to
  14615. */
  14616. goToFrame(frame: number): void;
  14617. /**
  14618. * @hidden Internal use only
  14619. */
  14620. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14621. /**
  14622. * Execute the current animation
  14623. * @param delay defines the delay to add to the current frame
  14624. * @param from defines the lower bound of the animation range
  14625. * @param to defines the upper bound of the animation range
  14626. * @param loop defines if the current animation must loop
  14627. * @param speedRatio defines the current speed ratio
  14628. * @param weight defines the weight of the animation (default is -1 so no weight)
  14629. * @param onLoop optional callback called when animation loops
  14630. * @returns a boolean indicating if the animation is running
  14631. */
  14632. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14633. }
  14634. }
  14635. declare module BABYLON {
  14636. /**
  14637. * Class used to store an actual running animation
  14638. */
  14639. export class Animatable {
  14640. /** defines the target object */
  14641. target: any;
  14642. /** defines the starting frame number (default is 0) */
  14643. fromFrame: number;
  14644. /** defines the ending frame number (default is 100) */
  14645. toFrame: number;
  14646. /** defines if the animation must loop (default is false) */
  14647. loopAnimation: boolean;
  14648. /** defines a callback to call when animation ends if it is not looping */
  14649. onAnimationEnd?: (() => void) | null | undefined;
  14650. /** defines a callback to call when animation loops */
  14651. onAnimationLoop?: (() => void) | null | undefined;
  14652. /** defines whether the animation should be evaluated additively */
  14653. isAdditive: boolean;
  14654. private _localDelayOffset;
  14655. private _pausedDelay;
  14656. private _runtimeAnimations;
  14657. private _paused;
  14658. private _scene;
  14659. private _speedRatio;
  14660. private _weight;
  14661. private _syncRoot;
  14662. /**
  14663. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14664. * This will only apply for non looping animation (default is true)
  14665. */
  14666. disposeOnEnd: boolean;
  14667. /**
  14668. * Gets a boolean indicating if the animation has started
  14669. */
  14670. animationStarted: boolean;
  14671. /**
  14672. * Observer raised when the animation ends
  14673. */
  14674. onAnimationEndObservable: Observable<Animatable>;
  14675. /**
  14676. * Observer raised when the animation loops
  14677. */
  14678. onAnimationLoopObservable: Observable<Animatable>;
  14679. /**
  14680. * Gets the root Animatable used to synchronize and normalize animations
  14681. */
  14682. get syncRoot(): Nullable<Animatable>;
  14683. /**
  14684. * Gets the current frame of the first RuntimeAnimation
  14685. * Used to synchronize Animatables
  14686. */
  14687. get masterFrame(): number;
  14688. /**
  14689. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14690. */
  14691. get weight(): number;
  14692. set weight(value: number);
  14693. /**
  14694. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14695. */
  14696. get speedRatio(): number;
  14697. set speedRatio(value: number);
  14698. /**
  14699. * Creates a new Animatable
  14700. * @param scene defines the hosting scene
  14701. * @param target defines the target object
  14702. * @param fromFrame defines the starting frame number (default is 0)
  14703. * @param toFrame defines the ending frame number (default is 100)
  14704. * @param loopAnimation defines if the animation must loop (default is false)
  14705. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14706. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14707. * @param animations defines a group of animation to add to the new Animatable
  14708. * @param onAnimationLoop defines a callback to call when animation loops
  14709. * @param isAdditive defines whether the animation should be evaluated additively
  14710. */
  14711. constructor(scene: Scene,
  14712. /** defines the target object */
  14713. target: any,
  14714. /** defines the starting frame number (default is 0) */
  14715. fromFrame?: number,
  14716. /** defines the ending frame number (default is 100) */
  14717. toFrame?: number,
  14718. /** defines if the animation must loop (default is false) */
  14719. loopAnimation?: boolean, speedRatio?: number,
  14720. /** defines a callback to call when animation ends if it is not looping */
  14721. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14722. /** defines a callback to call when animation loops */
  14723. onAnimationLoop?: (() => void) | null | undefined,
  14724. /** defines whether the animation should be evaluated additively */
  14725. isAdditive?: boolean);
  14726. /**
  14727. * Synchronize and normalize current Animatable with a source Animatable
  14728. * This is useful when using animation weights and when animations are not of the same length
  14729. * @param root defines the root Animatable to synchronize with
  14730. * @returns the current Animatable
  14731. */
  14732. syncWith(root: Animatable): Animatable;
  14733. /**
  14734. * Gets the list of runtime animations
  14735. * @returns an array of RuntimeAnimation
  14736. */
  14737. getAnimations(): RuntimeAnimation[];
  14738. /**
  14739. * Adds more animations to the current animatable
  14740. * @param target defines the target of the animations
  14741. * @param animations defines the new animations to add
  14742. */
  14743. appendAnimations(target: any, animations: Animation[]): void;
  14744. /**
  14745. * Gets the source animation for a specific property
  14746. * @param property defines the propertyu to look for
  14747. * @returns null or the source animation for the given property
  14748. */
  14749. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14750. /**
  14751. * Gets the runtime animation for a specific property
  14752. * @param property defines the propertyu to look for
  14753. * @returns null or the runtime animation for the given property
  14754. */
  14755. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14756. /**
  14757. * Resets the animatable to its original state
  14758. */
  14759. reset(): void;
  14760. /**
  14761. * Allows the animatable to blend with current running animations
  14762. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14763. * @param blendingSpeed defines the blending speed to use
  14764. */
  14765. enableBlending(blendingSpeed: number): void;
  14766. /**
  14767. * Disable animation blending
  14768. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14769. */
  14770. disableBlending(): void;
  14771. /**
  14772. * Jump directly to a given frame
  14773. * @param frame defines the frame to jump to
  14774. */
  14775. goToFrame(frame: number): void;
  14776. /**
  14777. * Pause the animation
  14778. */
  14779. pause(): void;
  14780. /**
  14781. * Restart the animation
  14782. */
  14783. restart(): void;
  14784. private _raiseOnAnimationEnd;
  14785. /**
  14786. * Stop and delete the current animation
  14787. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14788. * @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)
  14789. */
  14790. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14791. /**
  14792. * Wait asynchronously for the animation to end
  14793. * @returns a promise which will be fullfilled when the animation ends
  14794. */
  14795. waitAsync(): Promise<Animatable>;
  14796. /** @hidden */
  14797. _animate(delay: number): boolean;
  14798. }
  14799. interface Scene {
  14800. /** @hidden */
  14801. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14802. /** @hidden */
  14803. _processLateAnimationBindingsForMatrices(holder: {
  14804. totalWeight: number;
  14805. totalAdditiveWeight: number;
  14806. animations: RuntimeAnimation[];
  14807. additiveAnimations: RuntimeAnimation[];
  14808. originalValue: Matrix;
  14809. }): any;
  14810. /** @hidden */
  14811. _processLateAnimationBindingsForQuaternions(holder: {
  14812. totalWeight: number;
  14813. totalAdditiveWeight: number;
  14814. animations: RuntimeAnimation[];
  14815. additiveAnimations: RuntimeAnimation[];
  14816. originalValue: Quaternion;
  14817. }, refQuaternion: Quaternion): Quaternion;
  14818. /** @hidden */
  14819. _processLateAnimationBindings(): void;
  14820. /**
  14821. * Will start the animation sequence of a given target
  14822. * @param target defines the target
  14823. * @param from defines from which frame should animation start
  14824. * @param to defines until which frame should animation run.
  14825. * @param weight defines the weight to apply to the animation (1.0 by default)
  14826. * @param loop defines if the animation loops
  14827. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14828. * @param onAnimationEnd defines the function to be executed when the animation ends
  14829. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14830. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14831. * @param onAnimationLoop defines the callback to call when an animation loops
  14832. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14833. * @returns the animatable object created for this animation
  14834. */
  14835. 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;
  14836. /**
  14837. * Will start the animation sequence of a given target
  14838. * @param target defines the target
  14839. * @param from defines from which frame should animation start
  14840. * @param to defines until which frame should animation run.
  14841. * @param loop defines if the animation loops
  14842. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14843. * @param onAnimationEnd defines the function to be executed when the animation ends
  14844. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14845. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14846. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14847. * @param onAnimationLoop defines the callback to call when an animation loops
  14848. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14849. * @returns the animatable object created for this animation
  14850. */
  14851. 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;
  14852. /**
  14853. * Will start the animation sequence of a given target and its hierarchy
  14854. * @param target defines the target
  14855. * @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.
  14856. * @param from defines from which frame should animation start
  14857. * @param to defines until which frame should animation run.
  14858. * @param loop defines if the animation loops
  14859. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14860. * @param onAnimationEnd defines the function to be executed when the animation ends
  14861. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14862. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14863. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14864. * @param onAnimationLoop defines the callback to call when an animation loops
  14865. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14866. * @returns the list of created animatables
  14867. */
  14868. 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[];
  14869. /**
  14870. * Begin a new animation on a given node
  14871. * @param target defines the target where the animation will take place
  14872. * @param animations defines the list of animations to start
  14873. * @param from defines the initial value
  14874. * @param to defines the final value
  14875. * @param loop defines if you want animation to loop (off by default)
  14876. * @param speedRatio defines the speed ratio to apply to all animations
  14877. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14878. * @param onAnimationLoop defines the callback to call when an animation loops
  14879. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14880. * @returns the list of created animatables
  14881. */
  14882. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14883. /**
  14884. * Begin a new animation on a given node and its hierarchy
  14885. * @param target defines the root node where the animation will take place
  14886. * @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.
  14887. * @param animations defines the list of animations to start
  14888. * @param from defines the initial value
  14889. * @param to defines the final value
  14890. * @param loop defines if you want animation to loop (off by default)
  14891. * @param speedRatio defines the speed ratio to apply to all animations
  14892. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14893. * @param onAnimationLoop defines the callback to call when an animation loops
  14894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14895. * @returns the list of animatables created for all nodes
  14896. */
  14897. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14898. /**
  14899. * Gets the animatable associated with a specific target
  14900. * @param target defines the target of the animatable
  14901. * @returns the required animatable if found
  14902. */
  14903. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14904. /**
  14905. * Gets all animatables associated with a given target
  14906. * @param target defines the target to look animatables for
  14907. * @returns an array of Animatables
  14908. */
  14909. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14910. /**
  14911. * Stops and removes all animations that have been applied to the scene
  14912. */
  14913. stopAllAnimations(): void;
  14914. /**
  14915. * Gets the current delta time used by animation engine
  14916. */
  14917. deltaTime: number;
  14918. }
  14919. interface Bone {
  14920. /**
  14921. * Copy an animation range from another bone
  14922. * @param source defines the source bone
  14923. * @param rangeName defines the range name to copy
  14924. * @param frameOffset defines the frame offset
  14925. * @param rescaleAsRequired defines if rescaling must be applied if required
  14926. * @param skelDimensionsRatio defines the scaling ratio
  14927. * @returns true if operation was successful
  14928. */
  14929. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14930. }
  14931. }
  14932. declare module BABYLON {
  14933. /**
  14934. * Class used to handle skinning animations
  14935. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14936. */
  14937. export class Skeleton implements IAnimatable {
  14938. /** defines the skeleton name */
  14939. name: string;
  14940. /** defines the skeleton Id */
  14941. id: string;
  14942. /**
  14943. * Defines the list of child bones
  14944. */
  14945. bones: Bone[];
  14946. /**
  14947. * Defines an estimate of the dimension of the skeleton at rest
  14948. */
  14949. dimensionsAtRest: Vector3;
  14950. /**
  14951. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14952. */
  14953. needInitialSkinMatrix: boolean;
  14954. /**
  14955. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14956. */
  14957. overrideMesh: Nullable<AbstractMesh>;
  14958. /**
  14959. * Gets the list of animations attached to this skeleton
  14960. */
  14961. animations: Array<Animation>;
  14962. private _scene;
  14963. private _isDirty;
  14964. private _transformMatrices;
  14965. private _transformMatrixTexture;
  14966. private _meshesWithPoseMatrix;
  14967. private _animatables;
  14968. private _identity;
  14969. private _synchronizedWithMesh;
  14970. private _ranges;
  14971. private _lastAbsoluteTransformsUpdateId;
  14972. private _canUseTextureForBones;
  14973. private _uniqueId;
  14974. /** @hidden */
  14975. _numBonesWithLinkedTransformNode: number;
  14976. /** @hidden */
  14977. _hasWaitingData: Nullable<boolean>;
  14978. /**
  14979. * Specifies if the skeleton should be serialized
  14980. */
  14981. doNotSerialize: boolean;
  14982. private _useTextureToStoreBoneMatrices;
  14983. /**
  14984. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14985. * Please note that this option is not available if the hardware does not support it
  14986. */
  14987. get useTextureToStoreBoneMatrices(): boolean;
  14988. set useTextureToStoreBoneMatrices(value: boolean);
  14989. private _animationPropertiesOverride;
  14990. /**
  14991. * Gets or sets the animation properties override
  14992. */
  14993. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14994. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14995. /**
  14996. * List of inspectable custom properties (used by the Inspector)
  14997. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14998. */
  14999. inspectableCustomProperties: IInspectable[];
  15000. /**
  15001. * An observable triggered before computing the skeleton's matrices
  15002. */
  15003. onBeforeComputeObservable: Observable<Skeleton>;
  15004. /**
  15005. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15006. */
  15007. get isUsingTextureForMatrices(): boolean;
  15008. /**
  15009. * Gets the unique ID of this skeleton
  15010. */
  15011. get uniqueId(): number;
  15012. /**
  15013. * Creates a new skeleton
  15014. * @param name defines the skeleton name
  15015. * @param id defines the skeleton Id
  15016. * @param scene defines the hosting scene
  15017. */
  15018. constructor(
  15019. /** defines the skeleton name */
  15020. name: string,
  15021. /** defines the skeleton Id */
  15022. id: string, scene: Scene);
  15023. /**
  15024. * Gets the current object class name.
  15025. * @return the class name
  15026. */
  15027. getClassName(): string;
  15028. /**
  15029. * Returns an array containing the root bones
  15030. * @returns an array containing the root bones
  15031. */
  15032. getChildren(): Array<Bone>;
  15033. /**
  15034. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15035. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15036. * @returns a Float32Array containing matrices data
  15037. */
  15038. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15039. /**
  15040. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15041. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15042. * @returns a raw texture containing the data
  15043. */
  15044. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15045. /**
  15046. * Gets the current hosting scene
  15047. * @returns a scene object
  15048. */
  15049. getScene(): Scene;
  15050. /**
  15051. * Gets a string representing the current skeleton data
  15052. * @param fullDetails defines a boolean indicating if we want a verbose version
  15053. * @returns a string representing the current skeleton data
  15054. */
  15055. toString(fullDetails?: boolean): string;
  15056. /**
  15057. * Get bone's index searching by name
  15058. * @param name defines bone's name to search for
  15059. * @return the indice of the bone. Returns -1 if not found
  15060. */
  15061. getBoneIndexByName(name: string): number;
  15062. /**
  15063. * Creater a new animation range
  15064. * @param name defines the name of the range
  15065. * @param from defines the start key
  15066. * @param to defines the end key
  15067. */
  15068. createAnimationRange(name: string, from: number, to: number): void;
  15069. /**
  15070. * Delete a specific animation range
  15071. * @param name defines the name of the range
  15072. * @param deleteFrames defines if frames must be removed as well
  15073. */
  15074. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15075. /**
  15076. * Gets a specific animation range
  15077. * @param name defines the name of the range to look for
  15078. * @returns the requested animation range or null if not found
  15079. */
  15080. getAnimationRange(name: string): Nullable<AnimationRange>;
  15081. /**
  15082. * Gets the list of all animation ranges defined on this skeleton
  15083. * @returns an array
  15084. */
  15085. getAnimationRanges(): Nullable<AnimationRange>[];
  15086. /**
  15087. * Copy animation range from a source skeleton.
  15088. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15089. * @param source defines the source skeleton
  15090. * @param name defines the name of the range to copy
  15091. * @param rescaleAsRequired defines if rescaling must be applied if required
  15092. * @returns true if operation was successful
  15093. */
  15094. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15095. /**
  15096. * Forces the skeleton to go to rest pose
  15097. */
  15098. returnToRest(): void;
  15099. private _getHighestAnimationFrame;
  15100. /**
  15101. * Begin a specific animation range
  15102. * @param name defines the name of the range to start
  15103. * @param loop defines if looping must be turned on (false by default)
  15104. * @param speedRatio defines the speed ratio to apply (1 by default)
  15105. * @param onAnimationEnd defines a callback which will be called when animation will end
  15106. * @returns a new animatable
  15107. */
  15108. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15109. /**
  15110. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15111. * @param skeleton defines the Skeleton containing the animation range to convert
  15112. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15113. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15114. * @returns the original skeleton
  15115. */
  15116. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15117. /** @hidden */
  15118. _markAsDirty(): void;
  15119. /** @hidden */
  15120. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15121. /** @hidden */
  15122. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15123. private _computeTransformMatrices;
  15124. /**
  15125. * Build all resources required to render a skeleton
  15126. */
  15127. prepare(): void;
  15128. /**
  15129. * Gets the list of animatables currently running for this skeleton
  15130. * @returns an array of animatables
  15131. */
  15132. getAnimatables(): IAnimatable[];
  15133. /**
  15134. * Clone the current skeleton
  15135. * @param name defines the name of the new skeleton
  15136. * @param id defines the id of the new skeleton
  15137. * @returns the new skeleton
  15138. */
  15139. clone(name: string, id?: string): Skeleton;
  15140. /**
  15141. * Enable animation blending for this skeleton
  15142. * @param blendingSpeed defines the blending speed to apply
  15143. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15144. */
  15145. enableBlending(blendingSpeed?: number): void;
  15146. /**
  15147. * Releases all resources associated with the current skeleton
  15148. */
  15149. dispose(): void;
  15150. /**
  15151. * Serialize the skeleton in a JSON object
  15152. * @returns a JSON object
  15153. */
  15154. serialize(): any;
  15155. /**
  15156. * Creates a new skeleton from serialized data
  15157. * @param parsedSkeleton defines the serialized data
  15158. * @param scene defines the hosting scene
  15159. * @returns a new skeleton
  15160. */
  15161. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15162. /**
  15163. * Compute all node absolute transforms
  15164. * @param forceUpdate defines if computation must be done even if cache is up to date
  15165. */
  15166. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15167. /**
  15168. * Gets the root pose matrix
  15169. * @returns a matrix
  15170. */
  15171. getPoseMatrix(): Nullable<Matrix>;
  15172. /**
  15173. * Sorts bones per internal index
  15174. */
  15175. sortBones(): void;
  15176. private _sortBones;
  15177. }
  15178. }
  15179. declare module BABYLON {
  15180. /**
  15181. * Creates an instance based on a source mesh.
  15182. */
  15183. export class InstancedMesh extends AbstractMesh {
  15184. private _sourceMesh;
  15185. private _currentLOD;
  15186. /** @hidden */
  15187. _indexInSourceMeshInstanceArray: number;
  15188. constructor(name: string, source: Mesh);
  15189. /**
  15190. * Returns the string "InstancedMesh".
  15191. */
  15192. getClassName(): string;
  15193. /** Gets the list of lights affecting that mesh */
  15194. get lightSources(): Light[];
  15195. _resyncLightSources(): void;
  15196. _resyncLightSource(light: Light): void;
  15197. _removeLightSource(light: Light, dispose: boolean): void;
  15198. /**
  15199. * If the source mesh receives shadows
  15200. */
  15201. get receiveShadows(): boolean;
  15202. /**
  15203. * The material of the source mesh
  15204. */
  15205. get material(): Nullable<Material>;
  15206. /**
  15207. * Visibility of the source mesh
  15208. */
  15209. get visibility(): number;
  15210. /**
  15211. * Skeleton of the source mesh
  15212. */
  15213. get skeleton(): Nullable<Skeleton>;
  15214. /**
  15215. * Rendering ground id of the source mesh
  15216. */
  15217. get renderingGroupId(): number;
  15218. set renderingGroupId(value: number);
  15219. /**
  15220. * Returns the total number of vertices (integer).
  15221. */
  15222. getTotalVertices(): number;
  15223. /**
  15224. * Returns a positive integer : the total number of indices in this mesh geometry.
  15225. * @returns the numner of indices or zero if the mesh has no geometry.
  15226. */
  15227. getTotalIndices(): number;
  15228. /**
  15229. * The source mesh of the instance
  15230. */
  15231. get sourceMesh(): Mesh;
  15232. /**
  15233. * Is this node ready to be used/rendered
  15234. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15235. * @return {boolean} is it ready
  15236. */
  15237. isReady(completeCheck?: boolean): boolean;
  15238. /**
  15239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15240. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15241. * @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.
  15242. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15243. */
  15244. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15245. /**
  15246. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15247. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15248. * The `data` are either a numeric array either a Float32Array.
  15249. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15250. * 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).
  15251. * Note that a new underlying VertexBuffer object is created each call.
  15252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15253. *
  15254. * Possible `kind` values :
  15255. * - VertexBuffer.PositionKind
  15256. * - VertexBuffer.UVKind
  15257. * - VertexBuffer.UV2Kind
  15258. * - VertexBuffer.UV3Kind
  15259. * - VertexBuffer.UV4Kind
  15260. * - VertexBuffer.UV5Kind
  15261. * - VertexBuffer.UV6Kind
  15262. * - VertexBuffer.ColorKind
  15263. * - VertexBuffer.MatricesIndicesKind
  15264. * - VertexBuffer.MatricesIndicesExtraKind
  15265. * - VertexBuffer.MatricesWeightsKind
  15266. * - VertexBuffer.MatricesWeightsExtraKind
  15267. *
  15268. * Returns the Mesh.
  15269. */
  15270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15271. /**
  15272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15273. * If the mesh has no geometry, it is simply returned as it is.
  15274. * The `data` are either a numeric array either a Float32Array.
  15275. * No new underlying VertexBuffer object is created.
  15276. * 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.
  15277. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15278. *
  15279. * Possible `kind` values :
  15280. * - VertexBuffer.PositionKind
  15281. * - VertexBuffer.UVKind
  15282. * - VertexBuffer.UV2Kind
  15283. * - VertexBuffer.UV3Kind
  15284. * - VertexBuffer.UV4Kind
  15285. * - VertexBuffer.UV5Kind
  15286. * - VertexBuffer.UV6Kind
  15287. * - VertexBuffer.ColorKind
  15288. * - VertexBuffer.MatricesIndicesKind
  15289. * - VertexBuffer.MatricesIndicesExtraKind
  15290. * - VertexBuffer.MatricesWeightsKind
  15291. * - VertexBuffer.MatricesWeightsExtraKind
  15292. *
  15293. * Returns the Mesh.
  15294. */
  15295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15296. /**
  15297. * Sets the mesh indices.
  15298. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15299. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15300. * This method creates a new index buffer each call.
  15301. * Returns the Mesh.
  15302. */
  15303. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15304. /**
  15305. * Boolean : True if the mesh owns the requested kind of data.
  15306. */
  15307. isVerticesDataPresent(kind: string): boolean;
  15308. /**
  15309. * Returns an array of indices (IndicesArray).
  15310. */
  15311. getIndices(): Nullable<IndicesArray>;
  15312. get _positions(): Nullable<Vector3[]>;
  15313. /**
  15314. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15315. * This means the mesh underlying bounding box and sphere are recomputed.
  15316. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15317. * @returns the current mesh
  15318. */
  15319. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15320. /** @hidden */
  15321. _preActivate(): InstancedMesh;
  15322. /** @hidden */
  15323. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15324. /** @hidden */
  15325. _postActivate(): void;
  15326. getWorldMatrix(): Matrix;
  15327. get isAnInstance(): boolean;
  15328. /**
  15329. * Returns the current associated LOD AbstractMesh.
  15330. */
  15331. getLOD(camera: Camera): AbstractMesh;
  15332. /** @hidden */
  15333. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15334. /** @hidden */
  15335. _syncSubMeshes(): InstancedMesh;
  15336. /** @hidden */
  15337. _generatePointsArray(): boolean;
  15338. /**
  15339. * Creates a new InstancedMesh from the current mesh.
  15340. * - name (string) : the cloned mesh name
  15341. * - newParent (optional Node) : the optional Node to parent the clone to.
  15342. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15343. *
  15344. * Returns the clone.
  15345. */
  15346. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15347. /**
  15348. * Disposes the InstancedMesh.
  15349. * Returns nothing.
  15350. */
  15351. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15352. }
  15353. interface Mesh {
  15354. /**
  15355. * Register a custom buffer that will be instanced
  15356. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15357. * @param kind defines the buffer kind
  15358. * @param stride defines the stride in floats
  15359. */
  15360. registerInstancedBuffer(kind: string, stride: number): void;
  15361. /** @hidden */
  15362. _userInstancedBuffersStorage: {
  15363. data: {
  15364. [key: string]: Float32Array;
  15365. };
  15366. sizes: {
  15367. [key: string]: number;
  15368. };
  15369. vertexBuffers: {
  15370. [key: string]: Nullable<VertexBuffer>;
  15371. };
  15372. strides: {
  15373. [key: string]: number;
  15374. };
  15375. };
  15376. }
  15377. interface AbstractMesh {
  15378. /**
  15379. * Object used to store instanced buffers defined by user
  15380. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15381. */
  15382. instancedBuffers: {
  15383. [key: string]: any;
  15384. };
  15385. }
  15386. }
  15387. declare module BABYLON {
  15388. /**
  15389. * Defines the options associated with the creation of a shader material.
  15390. */
  15391. export interface IShaderMaterialOptions {
  15392. /**
  15393. * Does the material work in alpha blend mode
  15394. */
  15395. needAlphaBlending: boolean;
  15396. /**
  15397. * Does the material work in alpha test mode
  15398. */
  15399. needAlphaTesting: boolean;
  15400. /**
  15401. * The list of attribute names used in the shader
  15402. */
  15403. attributes: string[];
  15404. /**
  15405. * The list of unifrom names used in the shader
  15406. */
  15407. uniforms: string[];
  15408. /**
  15409. * The list of UBO names used in the shader
  15410. */
  15411. uniformBuffers: string[];
  15412. /**
  15413. * The list of sampler names used in the shader
  15414. */
  15415. samplers: string[];
  15416. /**
  15417. * The list of defines used in the shader
  15418. */
  15419. defines: string[];
  15420. }
  15421. /**
  15422. * 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.
  15423. *
  15424. * This returned material effects how the mesh will look based on the code in the shaders.
  15425. *
  15426. * @see http://doc.babylonjs.com/how_to/shader_material
  15427. */
  15428. export class ShaderMaterial extends Material {
  15429. private _shaderPath;
  15430. private _options;
  15431. private _textures;
  15432. private _textureArrays;
  15433. private _floats;
  15434. private _ints;
  15435. private _floatsArrays;
  15436. private _colors3;
  15437. private _colors3Arrays;
  15438. private _colors4;
  15439. private _colors4Arrays;
  15440. private _vectors2;
  15441. private _vectors3;
  15442. private _vectors4;
  15443. private _matrices;
  15444. private _matrixArrays;
  15445. private _matrices3x3;
  15446. private _matrices2x2;
  15447. private _vectors2Arrays;
  15448. private _vectors3Arrays;
  15449. private _vectors4Arrays;
  15450. private _cachedWorldViewMatrix;
  15451. private _cachedWorldViewProjectionMatrix;
  15452. private _renderId;
  15453. private _multiview;
  15454. /**
  15455. * Instantiate a new shader material.
  15456. * 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.
  15457. * This returned material effects how the mesh will look based on the code in the shaders.
  15458. * @see http://doc.babylonjs.com/how_to/shader_material
  15459. * @param name Define the name of the material in the scene
  15460. * @param scene Define the scene the material belongs to
  15461. * @param shaderPath Defines the route to the shader code in one of three ways:
  15462. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15463. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15464. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15465. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15466. * @param options Define the options used to create the shader
  15467. */
  15468. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15469. /**
  15470. * Gets the shader path used to define the shader code
  15471. * It can be modified to trigger a new compilation
  15472. */
  15473. get shaderPath(): any;
  15474. /**
  15475. * Sets the shader path used to define the shader code
  15476. * It can be modified to trigger a new compilation
  15477. */
  15478. set shaderPath(shaderPath: any);
  15479. /**
  15480. * Gets the options used to compile the shader.
  15481. * They can be modified to trigger a new compilation
  15482. */
  15483. get options(): IShaderMaterialOptions;
  15484. /**
  15485. * Gets the current class name of the material e.g. "ShaderMaterial"
  15486. * Mainly use in serialization.
  15487. * @returns the class name
  15488. */
  15489. getClassName(): string;
  15490. /**
  15491. * Specifies if the material will require alpha blending
  15492. * @returns a boolean specifying if alpha blending is needed
  15493. */
  15494. needAlphaBlending(): boolean;
  15495. /**
  15496. * Specifies if this material should be rendered in alpha test mode
  15497. * @returns a boolean specifying if an alpha test is needed.
  15498. */
  15499. needAlphaTesting(): boolean;
  15500. private _checkUniform;
  15501. /**
  15502. * Set a texture in the shader.
  15503. * @param name Define the name of the uniform samplers as defined in the shader
  15504. * @param texture Define the texture to bind to this sampler
  15505. * @return the material itself allowing "fluent" like uniform updates
  15506. */
  15507. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15508. /**
  15509. * Set a texture array in the shader.
  15510. * @param name Define the name of the uniform sampler array as defined in the shader
  15511. * @param textures Define the list of textures to bind to this sampler
  15512. * @return the material itself allowing "fluent" like uniform updates
  15513. */
  15514. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15515. /**
  15516. * Set a float in the shader.
  15517. * @param name Define the name of the uniform as defined in the shader
  15518. * @param value Define the value to give to the uniform
  15519. * @return the material itself allowing "fluent" like uniform updates
  15520. */
  15521. setFloat(name: string, value: number): ShaderMaterial;
  15522. /**
  15523. * Set a int in the shader.
  15524. * @param name Define the name of the uniform as defined in the shader
  15525. * @param value Define the value to give to the uniform
  15526. * @return the material itself allowing "fluent" like uniform updates
  15527. */
  15528. setInt(name: string, value: number): ShaderMaterial;
  15529. /**
  15530. * Set an array of floats in the shader.
  15531. * @param name Define the name of the uniform as defined in the shader
  15532. * @param value Define the value to give to the uniform
  15533. * @return the material itself allowing "fluent" like uniform updates
  15534. */
  15535. setFloats(name: string, value: number[]): ShaderMaterial;
  15536. /**
  15537. * Set a vec3 in the shader from a Color3.
  15538. * @param name Define the name of the uniform as defined in the shader
  15539. * @param value Define the value to give to the uniform
  15540. * @return the material itself allowing "fluent" like uniform updates
  15541. */
  15542. setColor3(name: string, value: Color3): ShaderMaterial;
  15543. /**
  15544. * Set a vec3 array in the shader from a Color3 array.
  15545. * @param name Define the name of the uniform as defined in the shader
  15546. * @param value Define the value to give to the uniform
  15547. * @return the material itself allowing "fluent" like uniform updates
  15548. */
  15549. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15550. /**
  15551. * Set a vec4 in the shader from a Color4.
  15552. * @param name Define the name of the uniform as defined in the shader
  15553. * @param value Define the value to give to the uniform
  15554. * @return the material itself allowing "fluent" like uniform updates
  15555. */
  15556. setColor4(name: string, value: Color4): ShaderMaterial;
  15557. /**
  15558. * Set a vec4 array in the shader from a Color4 array.
  15559. * @param name Define the name of the uniform as defined in the shader
  15560. * @param value Define the value to give to the uniform
  15561. * @return the material itself allowing "fluent" like uniform updates
  15562. */
  15563. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15564. /**
  15565. * Set a vec2 in the shader from a Vector2.
  15566. * @param name Define the name of the uniform as defined in the shader
  15567. * @param value Define the value to give to the uniform
  15568. * @return the material itself allowing "fluent" like uniform updates
  15569. */
  15570. setVector2(name: string, value: Vector2): ShaderMaterial;
  15571. /**
  15572. * Set a vec3 in the shader from a Vector3.
  15573. * @param name Define the name of the uniform as defined in the shader
  15574. * @param value Define the value to give to the uniform
  15575. * @return the material itself allowing "fluent" like uniform updates
  15576. */
  15577. setVector3(name: string, value: Vector3): ShaderMaterial;
  15578. /**
  15579. * Set a vec4 in the shader from a Vector4.
  15580. * @param name Define the name of the uniform as defined in the shader
  15581. * @param value Define the value to give to the uniform
  15582. * @return the material itself allowing "fluent" like uniform updates
  15583. */
  15584. setVector4(name: string, value: Vector4): ShaderMaterial;
  15585. /**
  15586. * Set a mat4 in the shader from a Matrix.
  15587. * @param name Define the name of the uniform as defined in the shader
  15588. * @param value Define the value to give to the uniform
  15589. * @return the material itself allowing "fluent" like uniform updates
  15590. */
  15591. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15592. /**
  15593. * Set a float32Array in the shader from a matrix array.
  15594. * @param name Define the name of the uniform as defined in the shader
  15595. * @param value Define the value to give to the uniform
  15596. * @return the material itself allowing "fluent" like uniform updates
  15597. */
  15598. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15599. /**
  15600. * Set a mat3 in the shader from a Float32Array.
  15601. * @param name Define the name of the uniform as defined in the shader
  15602. * @param value Define the value to give to the uniform
  15603. * @return the material itself allowing "fluent" like uniform updates
  15604. */
  15605. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15606. /**
  15607. * Set a mat2 in the shader from a Float32Array.
  15608. * @param name Define the name of the uniform as defined in the shader
  15609. * @param value Define the value to give to the uniform
  15610. * @return the material itself allowing "fluent" like uniform updates
  15611. */
  15612. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15613. /**
  15614. * Set a vec2 array in the shader from a number array.
  15615. * @param name Define the name of the uniform as defined in the shader
  15616. * @param value Define the value to give to the uniform
  15617. * @return the material itself allowing "fluent" like uniform updates
  15618. */
  15619. setArray2(name: string, value: number[]): ShaderMaterial;
  15620. /**
  15621. * Set a vec3 array in the shader from a number array.
  15622. * @param name Define the name of the uniform as defined in the shader
  15623. * @param value Define the value to give to the uniform
  15624. * @return the material itself allowing "fluent" like uniform updates
  15625. */
  15626. setArray3(name: string, value: number[]): ShaderMaterial;
  15627. /**
  15628. * Set a vec4 array in the shader from a number array.
  15629. * @param name Define the name of the uniform as defined in the shader
  15630. * @param value Define the value to give to the uniform
  15631. * @return the material itself allowing "fluent" like uniform updates
  15632. */
  15633. setArray4(name: string, value: number[]): ShaderMaterial;
  15634. private _checkCache;
  15635. /**
  15636. * Specifies that the submesh is ready to be used
  15637. * @param mesh defines the mesh to check
  15638. * @param subMesh defines which submesh to check
  15639. * @param useInstances specifies that instances should be used
  15640. * @returns a boolean indicating that the submesh is ready or not
  15641. */
  15642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15643. /**
  15644. * Checks if the material is ready to render the requested mesh
  15645. * @param mesh Define the mesh to render
  15646. * @param useInstances Define whether or not the material is used with instances
  15647. * @returns true if ready, otherwise false
  15648. */
  15649. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15650. /**
  15651. * Binds the world matrix to the material
  15652. * @param world defines the world transformation matrix
  15653. */
  15654. bindOnlyWorldMatrix(world: Matrix): void;
  15655. /**
  15656. * Binds the material to the mesh
  15657. * @param world defines the world transformation matrix
  15658. * @param mesh defines the mesh to bind the material to
  15659. */
  15660. bind(world: Matrix, mesh?: Mesh): void;
  15661. /**
  15662. * Gets the active textures from the material
  15663. * @returns an array of textures
  15664. */
  15665. getActiveTextures(): BaseTexture[];
  15666. /**
  15667. * Specifies if the material uses a texture
  15668. * @param texture defines the texture to check against the material
  15669. * @returns a boolean specifying if the material uses the texture
  15670. */
  15671. hasTexture(texture: BaseTexture): boolean;
  15672. /**
  15673. * Makes a duplicate of the material, and gives it a new name
  15674. * @param name defines the new name for the duplicated material
  15675. * @returns the cloned material
  15676. */
  15677. clone(name: string): ShaderMaterial;
  15678. /**
  15679. * Disposes the material
  15680. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15681. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15682. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15683. */
  15684. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15685. /**
  15686. * Serializes this material in a JSON representation
  15687. * @returns the serialized material object
  15688. */
  15689. serialize(): any;
  15690. /**
  15691. * Creates a shader material from parsed shader material data
  15692. * @param source defines the JSON represnetation of the material
  15693. * @param scene defines the hosting scene
  15694. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15695. * @returns a new material
  15696. */
  15697. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15698. }
  15699. }
  15700. declare module BABYLON {
  15701. /** @hidden */
  15702. export var colorPixelShader: {
  15703. name: string;
  15704. shader: string;
  15705. };
  15706. }
  15707. declare module BABYLON {
  15708. /** @hidden */
  15709. export var colorVertexShader: {
  15710. name: string;
  15711. shader: string;
  15712. };
  15713. }
  15714. declare module BABYLON {
  15715. /**
  15716. * Line mesh
  15717. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15718. */
  15719. export class LinesMesh extends Mesh {
  15720. /**
  15721. * If vertex color should be applied to the mesh
  15722. */
  15723. readonly useVertexColor?: boolean | undefined;
  15724. /**
  15725. * If vertex alpha should be applied to the mesh
  15726. */
  15727. readonly useVertexAlpha?: boolean | undefined;
  15728. /**
  15729. * Color of the line (Default: White)
  15730. */
  15731. color: Color3;
  15732. /**
  15733. * Alpha of the line (Default: 1)
  15734. */
  15735. alpha: number;
  15736. /**
  15737. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15738. * This margin is expressed in world space coordinates, so its value may vary.
  15739. * Default value is 0.1
  15740. */
  15741. intersectionThreshold: number;
  15742. private _colorShader;
  15743. private color4;
  15744. /**
  15745. * Creates a new LinesMesh
  15746. * @param name defines the name
  15747. * @param scene defines the hosting scene
  15748. * @param parent defines the parent mesh if any
  15749. * @param source defines the optional source LinesMesh used to clone data from
  15750. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15751. * When false, achieved by calling a clone(), also passing False.
  15752. * This will make creation of children, recursive.
  15753. * @param useVertexColor defines if this LinesMesh supports vertex color
  15754. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15755. */
  15756. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15757. /**
  15758. * If vertex color should be applied to the mesh
  15759. */
  15760. useVertexColor?: boolean | undefined,
  15761. /**
  15762. * If vertex alpha should be applied to the mesh
  15763. */
  15764. useVertexAlpha?: boolean | undefined);
  15765. private _addClipPlaneDefine;
  15766. private _removeClipPlaneDefine;
  15767. isReady(): boolean;
  15768. /**
  15769. * Returns the string "LineMesh"
  15770. */
  15771. getClassName(): string;
  15772. /**
  15773. * @hidden
  15774. */
  15775. get material(): Material;
  15776. /**
  15777. * @hidden
  15778. */
  15779. set material(value: Material);
  15780. /**
  15781. * @hidden
  15782. */
  15783. get checkCollisions(): boolean;
  15784. /** @hidden */
  15785. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15786. /** @hidden */
  15787. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15788. /**
  15789. * Disposes of the line mesh
  15790. * @param doNotRecurse If children should be disposed
  15791. */
  15792. dispose(doNotRecurse?: boolean): void;
  15793. /**
  15794. * Returns a new LineMesh object cloned from the current one.
  15795. */
  15796. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15797. /**
  15798. * Creates a new InstancedLinesMesh object from the mesh model.
  15799. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15800. * @param name defines the name of the new instance
  15801. * @returns a new InstancedLinesMesh
  15802. */
  15803. createInstance(name: string): InstancedLinesMesh;
  15804. }
  15805. /**
  15806. * Creates an instance based on a source LinesMesh
  15807. */
  15808. export class InstancedLinesMesh extends InstancedMesh {
  15809. /**
  15810. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15811. * This margin is expressed in world space coordinates, so its value may vary.
  15812. * Initilized with the intersectionThreshold value of the source LinesMesh
  15813. */
  15814. intersectionThreshold: number;
  15815. constructor(name: string, source: LinesMesh);
  15816. /**
  15817. * Returns the string "InstancedLinesMesh".
  15818. */
  15819. getClassName(): string;
  15820. }
  15821. }
  15822. declare module BABYLON {
  15823. /** @hidden */
  15824. export var linePixelShader: {
  15825. name: string;
  15826. shader: string;
  15827. };
  15828. }
  15829. declare module BABYLON {
  15830. /** @hidden */
  15831. export var lineVertexShader: {
  15832. name: string;
  15833. shader: string;
  15834. };
  15835. }
  15836. declare module BABYLON {
  15837. interface AbstractMesh {
  15838. /**
  15839. * Gets the edgesRenderer associated with the mesh
  15840. */
  15841. edgesRenderer: Nullable<EdgesRenderer>;
  15842. }
  15843. interface LinesMesh {
  15844. /**
  15845. * Enables the edge rendering mode on the mesh.
  15846. * This mode makes the mesh edges visible
  15847. * @param epsilon defines the maximal distance between two angles to detect a face
  15848. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15849. * @returns the currentAbstractMesh
  15850. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15851. */
  15852. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15853. }
  15854. interface InstancedLinesMesh {
  15855. /**
  15856. * Enables the edge rendering mode on the mesh.
  15857. * This mode makes the mesh edges visible
  15858. * @param epsilon defines the maximal distance between two angles to detect a face
  15859. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15860. * @returns the current InstancedLinesMesh
  15861. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15862. */
  15863. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15864. }
  15865. /**
  15866. * Defines the minimum contract an Edges renderer should follow.
  15867. */
  15868. export interface IEdgesRenderer extends IDisposable {
  15869. /**
  15870. * Gets or sets a boolean indicating if the edgesRenderer is active
  15871. */
  15872. isEnabled: boolean;
  15873. /**
  15874. * Renders the edges of the attached mesh,
  15875. */
  15876. render(): void;
  15877. /**
  15878. * Checks wether or not the edges renderer is ready to render.
  15879. * @return true if ready, otherwise false.
  15880. */
  15881. isReady(): boolean;
  15882. }
  15883. /**
  15884. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15885. */
  15886. export class EdgesRenderer implements IEdgesRenderer {
  15887. /**
  15888. * Define the size of the edges with an orthographic camera
  15889. */
  15890. edgesWidthScalerForOrthographic: number;
  15891. /**
  15892. * Define the size of the edges with a perspective camera
  15893. */
  15894. edgesWidthScalerForPerspective: number;
  15895. protected _source: AbstractMesh;
  15896. protected _linesPositions: number[];
  15897. protected _linesNormals: number[];
  15898. protected _linesIndices: number[];
  15899. protected _epsilon: number;
  15900. protected _indicesCount: number;
  15901. protected _lineShader: ShaderMaterial;
  15902. protected _ib: DataBuffer;
  15903. protected _buffers: {
  15904. [key: string]: Nullable<VertexBuffer>;
  15905. };
  15906. protected _checkVerticesInsteadOfIndices: boolean;
  15907. private _meshRebuildObserver;
  15908. private _meshDisposeObserver;
  15909. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15910. isEnabled: boolean;
  15911. /**
  15912. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15913. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15914. * @param source Mesh used to create edges
  15915. * @param epsilon sum of angles in adjacency to check for edge
  15916. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15917. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15918. */
  15919. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15920. protected _prepareRessources(): void;
  15921. /** @hidden */
  15922. _rebuild(): void;
  15923. /**
  15924. * Releases the required resources for the edges renderer
  15925. */
  15926. dispose(): void;
  15927. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15928. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15929. /**
  15930. * Checks if the pair of p0 and p1 is en edge
  15931. * @param faceIndex
  15932. * @param edge
  15933. * @param faceNormals
  15934. * @param p0
  15935. * @param p1
  15936. * @private
  15937. */
  15938. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15939. /**
  15940. * push line into the position, normal and index buffer
  15941. * @protected
  15942. */
  15943. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15944. /**
  15945. * Generates lines edges from adjacencjes
  15946. * @private
  15947. */
  15948. _generateEdgesLines(): void;
  15949. /**
  15950. * Checks wether or not the edges renderer is ready to render.
  15951. * @return true if ready, otherwise false.
  15952. */
  15953. isReady(): boolean;
  15954. /**
  15955. * Renders the edges of the attached mesh,
  15956. */
  15957. render(): void;
  15958. }
  15959. /**
  15960. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15961. */
  15962. export class LineEdgesRenderer extends EdgesRenderer {
  15963. /**
  15964. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15965. * @param source LineMesh used to generate edges
  15966. * @param epsilon not important (specified angle for edge detection)
  15967. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15968. */
  15969. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15970. /**
  15971. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15972. */
  15973. _generateEdgesLines(): void;
  15974. }
  15975. }
  15976. declare module BABYLON {
  15977. /**
  15978. * This represents the object necessary to create a rendering group.
  15979. * This is exclusively used and created by the rendering manager.
  15980. * To modify the behavior, you use the available helpers in your scene or meshes.
  15981. * @hidden
  15982. */
  15983. export class RenderingGroup {
  15984. index: number;
  15985. private static _zeroVector;
  15986. private _scene;
  15987. private _opaqueSubMeshes;
  15988. private _transparentSubMeshes;
  15989. private _alphaTestSubMeshes;
  15990. private _depthOnlySubMeshes;
  15991. private _particleSystems;
  15992. private _spriteManagers;
  15993. private _opaqueSortCompareFn;
  15994. private _alphaTestSortCompareFn;
  15995. private _transparentSortCompareFn;
  15996. private _renderOpaque;
  15997. private _renderAlphaTest;
  15998. private _renderTransparent;
  15999. /** @hidden */
  16000. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16001. onBeforeTransparentRendering: () => void;
  16002. /**
  16003. * Set the opaque sort comparison function.
  16004. * If null the sub meshes will be render in the order they were created
  16005. */
  16006. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16007. /**
  16008. * Set the alpha test sort comparison function.
  16009. * If null the sub meshes will be render in the order they were created
  16010. */
  16011. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16012. /**
  16013. * Set the transparent sort comparison function.
  16014. * If null the sub meshes will be render in the order they were created
  16015. */
  16016. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16017. /**
  16018. * Creates a new rendering group.
  16019. * @param index The rendering group index
  16020. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16021. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16022. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16023. */
  16024. 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>);
  16025. /**
  16026. * Render all the sub meshes contained in the group.
  16027. * @param customRenderFunction Used to override the default render behaviour of the group.
  16028. * @returns true if rendered some submeshes.
  16029. */
  16030. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16031. /**
  16032. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16033. * @param subMeshes The submeshes to render
  16034. */
  16035. private renderOpaqueSorted;
  16036. /**
  16037. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16038. * @param subMeshes The submeshes to render
  16039. */
  16040. private renderAlphaTestSorted;
  16041. /**
  16042. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16043. * @param subMeshes The submeshes to render
  16044. */
  16045. private renderTransparentSorted;
  16046. /**
  16047. * Renders the submeshes in a specified order.
  16048. * @param subMeshes The submeshes to sort before render
  16049. * @param sortCompareFn The comparison function use to sort
  16050. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16051. * @param transparent Specifies to activate blending if true
  16052. */
  16053. private static renderSorted;
  16054. /**
  16055. * Renders the submeshes in the order they were dispatched (no sort applied).
  16056. * @param subMeshes The submeshes to render
  16057. */
  16058. private static renderUnsorted;
  16059. /**
  16060. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16061. * are rendered back to front if in the same alpha index.
  16062. *
  16063. * @param a The first submesh
  16064. * @param b The second submesh
  16065. * @returns The result of the comparison
  16066. */
  16067. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16068. /**
  16069. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16070. * are rendered back to front.
  16071. *
  16072. * @param a The first submesh
  16073. * @param b The second submesh
  16074. * @returns The result of the comparison
  16075. */
  16076. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16077. /**
  16078. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16079. * are rendered front to back (prevent overdraw).
  16080. *
  16081. * @param a The first submesh
  16082. * @param b The second submesh
  16083. * @returns The result of the comparison
  16084. */
  16085. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16086. /**
  16087. * Resets the different lists of submeshes to prepare a new frame.
  16088. */
  16089. prepare(): void;
  16090. dispose(): void;
  16091. /**
  16092. * Inserts the submesh in its correct queue depending on its material.
  16093. * @param subMesh The submesh to dispatch
  16094. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16095. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16096. */
  16097. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16098. dispatchSprites(spriteManager: ISpriteManager): void;
  16099. dispatchParticles(particleSystem: IParticleSystem): void;
  16100. private _renderParticles;
  16101. private _renderSprites;
  16102. }
  16103. }
  16104. declare module BABYLON {
  16105. /**
  16106. * Interface describing the different options available in the rendering manager
  16107. * regarding Auto Clear between groups.
  16108. */
  16109. export interface IRenderingManagerAutoClearSetup {
  16110. /**
  16111. * Defines whether or not autoclear is enable.
  16112. */
  16113. autoClear: boolean;
  16114. /**
  16115. * Defines whether or not to autoclear the depth buffer.
  16116. */
  16117. depth: boolean;
  16118. /**
  16119. * Defines whether or not to autoclear the stencil buffer.
  16120. */
  16121. stencil: boolean;
  16122. }
  16123. /**
  16124. * This class is used by the onRenderingGroupObservable
  16125. */
  16126. export class RenderingGroupInfo {
  16127. /**
  16128. * The Scene that being rendered
  16129. */
  16130. scene: Scene;
  16131. /**
  16132. * The camera currently used for the rendering pass
  16133. */
  16134. camera: Nullable<Camera>;
  16135. /**
  16136. * The ID of the renderingGroup being processed
  16137. */
  16138. renderingGroupId: number;
  16139. }
  16140. /**
  16141. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16142. * It is enable to manage the different groups as well as the different necessary sort functions.
  16143. * This should not be used directly aside of the few static configurations
  16144. */
  16145. export class RenderingManager {
  16146. /**
  16147. * The max id used for rendering groups (not included)
  16148. */
  16149. static MAX_RENDERINGGROUPS: number;
  16150. /**
  16151. * The min id used for rendering groups (included)
  16152. */
  16153. static MIN_RENDERINGGROUPS: number;
  16154. /**
  16155. * Used to globally prevent autoclearing scenes.
  16156. */
  16157. static AUTOCLEAR: boolean;
  16158. /**
  16159. * @hidden
  16160. */
  16161. _useSceneAutoClearSetup: boolean;
  16162. private _scene;
  16163. private _renderingGroups;
  16164. private _depthStencilBufferAlreadyCleaned;
  16165. private _autoClearDepthStencil;
  16166. private _customOpaqueSortCompareFn;
  16167. private _customAlphaTestSortCompareFn;
  16168. private _customTransparentSortCompareFn;
  16169. private _renderingGroupInfo;
  16170. /**
  16171. * Instantiates a new rendering group for a particular scene
  16172. * @param scene Defines the scene the groups belongs to
  16173. */
  16174. constructor(scene: Scene);
  16175. private _clearDepthStencilBuffer;
  16176. /**
  16177. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16178. * @hidden
  16179. */
  16180. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16181. /**
  16182. * Resets the different information of the group to prepare a new frame
  16183. * @hidden
  16184. */
  16185. reset(): void;
  16186. /**
  16187. * Dispose and release the group and its associated resources.
  16188. * @hidden
  16189. */
  16190. dispose(): void;
  16191. /**
  16192. * Clear the info related to rendering groups preventing retention points during dispose.
  16193. */
  16194. freeRenderingGroups(): void;
  16195. private _prepareRenderingGroup;
  16196. /**
  16197. * Add a sprite manager to the rendering manager in order to render it this frame.
  16198. * @param spriteManager Define the sprite manager to render
  16199. */
  16200. dispatchSprites(spriteManager: ISpriteManager): void;
  16201. /**
  16202. * Add a particle system to the rendering manager in order to render it this frame.
  16203. * @param particleSystem Define the particle system to render
  16204. */
  16205. dispatchParticles(particleSystem: IParticleSystem): void;
  16206. /**
  16207. * Add a submesh to the manager in order to render it this frame
  16208. * @param subMesh The submesh to dispatch
  16209. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16210. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16211. */
  16212. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16213. /**
  16214. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16215. * This allowed control for front to back rendering or reversly depending of the special needs.
  16216. *
  16217. * @param renderingGroupId The rendering group id corresponding to its index
  16218. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16219. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16220. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16221. */
  16222. 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;
  16223. /**
  16224. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16225. *
  16226. * @param renderingGroupId The rendering group id corresponding to its index
  16227. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16228. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16229. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16230. */
  16231. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16232. /**
  16233. * Gets the current auto clear configuration for one rendering group of the rendering
  16234. * manager.
  16235. * @param index the rendering group index to get the information for
  16236. * @returns The auto clear setup for the requested rendering group
  16237. */
  16238. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16239. }
  16240. }
  16241. declare module BABYLON {
  16242. /**
  16243. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16244. */
  16245. export interface ICustomShaderOptions {
  16246. /**
  16247. * Gets or sets the custom shader name to use
  16248. */
  16249. shaderName: string;
  16250. /**
  16251. * The list of attribute names used in the shader
  16252. */
  16253. attributes?: string[];
  16254. /**
  16255. * The list of unifrom names used in the shader
  16256. */
  16257. uniforms?: string[];
  16258. /**
  16259. * The list of sampler names used in the shader
  16260. */
  16261. samplers?: string[];
  16262. /**
  16263. * The list of defines used in the shader
  16264. */
  16265. defines?: string[];
  16266. }
  16267. /**
  16268. * Interface to implement to create a shadow generator compatible with BJS.
  16269. */
  16270. export interface IShadowGenerator {
  16271. /**
  16272. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16273. * @returns The render target texture if present otherwise, null
  16274. */
  16275. getShadowMap(): Nullable<RenderTargetTexture>;
  16276. /**
  16277. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16278. * @param subMesh The submesh we want to render in the shadow map
  16279. * @param useInstances Defines wether will draw in the map using instances
  16280. * @returns true if ready otherwise, false
  16281. */
  16282. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16283. /**
  16284. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16285. * @param defines Defines of the material we want to update
  16286. * @param lightIndex Index of the light in the enabled light list of the material
  16287. */
  16288. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16289. /**
  16290. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16291. * defined in the generator but impacting the effect).
  16292. * It implies the unifroms available on the materials are the standard BJS ones.
  16293. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16294. * @param effect The effect we are binfing the information for
  16295. */
  16296. bindShadowLight(lightIndex: string, effect: Effect): void;
  16297. /**
  16298. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16299. * (eq to shadow prjection matrix * light transform matrix)
  16300. * @returns The transform matrix used to create the shadow map
  16301. */
  16302. getTransformMatrix(): Matrix;
  16303. /**
  16304. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16305. * Cube and 2D textures for instance.
  16306. */
  16307. recreateShadowMap(): void;
  16308. /**
  16309. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16310. * @param onCompiled Callback triggered at the and of the effects compilation
  16311. * @param options Sets of optional options forcing the compilation with different modes
  16312. */
  16313. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16314. useInstances: boolean;
  16315. }>): void;
  16316. /**
  16317. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16318. * @param options Sets of optional options forcing the compilation with different modes
  16319. * @returns A promise that resolves when the compilation completes
  16320. */
  16321. forceCompilationAsync(options?: Partial<{
  16322. useInstances: boolean;
  16323. }>): Promise<void>;
  16324. /**
  16325. * Serializes the shadow generator setup to a json object.
  16326. * @returns The serialized JSON object
  16327. */
  16328. serialize(): any;
  16329. /**
  16330. * Disposes the Shadow map and related Textures and effects.
  16331. */
  16332. dispose(): void;
  16333. }
  16334. /**
  16335. * Default implementation IShadowGenerator.
  16336. * This is the main object responsible of generating shadows in the framework.
  16337. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16338. */
  16339. export class ShadowGenerator implements IShadowGenerator {
  16340. /**
  16341. * Name of the shadow generator class
  16342. */
  16343. static CLASSNAME: string;
  16344. /**
  16345. * Shadow generator mode None: no filtering applied.
  16346. */
  16347. static readonly FILTER_NONE: number;
  16348. /**
  16349. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16350. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16351. */
  16352. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16353. /**
  16354. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16355. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16356. */
  16357. static readonly FILTER_POISSONSAMPLING: number;
  16358. /**
  16359. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16360. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16361. */
  16362. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16363. /**
  16364. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16365. * edge artifacts on steep falloff.
  16366. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16367. */
  16368. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16369. /**
  16370. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16371. * edge artifacts on steep falloff.
  16372. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16373. */
  16374. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16375. /**
  16376. * Shadow generator mode PCF: Percentage Closer Filtering
  16377. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16378. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16379. */
  16380. static readonly FILTER_PCF: number;
  16381. /**
  16382. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16383. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16384. * Contact Hardening
  16385. */
  16386. static readonly FILTER_PCSS: number;
  16387. /**
  16388. * Reserved for PCF and PCSS
  16389. * Highest Quality.
  16390. *
  16391. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16392. *
  16393. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16394. */
  16395. static readonly QUALITY_HIGH: number;
  16396. /**
  16397. * Reserved for PCF and PCSS
  16398. * Good tradeoff for quality/perf cross devices
  16399. *
  16400. * Execute PCF on a 3*3 kernel.
  16401. *
  16402. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16403. */
  16404. static readonly QUALITY_MEDIUM: number;
  16405. /**
  16406. * Reserved for PCF and PCSS
  16407. * The lowest quality but the fastest.
  16408. *
  16409. * Execute PCF on a 1*1 kernel.
  16410. *
  16411. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16412. */
  16413. static readonly QUALITY_LOW: number;
  16414. /** Gets or sets the custom shader name to use */
  16415. customShaderOptions: ICustomShaderOptions;
  16416. /**
  16417. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16418. */
  16419. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16420. /**
  16421. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16422. */
  16423. onAfterShadowMapRenderObservable: Observable<Effect>;
  16424. /**
  16425. * Observable triggered before a mesh is rendered in the shadow map.
  16426. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16427. */
  16428. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16429. /**
  16430. * Observable triggered after a mesh is rendered in the shadow map.
  16431. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16432. */
  16433. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16434. protected _bias: number;
  16435. /**
  16436. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16437. */
  16438. get bias(): number;
  16439. /**
  16440. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16441. */
  16442. set bias(bias: number);
  16443. protected _normalBias: number;
  16444. /**
  16445. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16446. */
  16447. get normalBias(): number;
  16448. /**
  16449. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16450. */
  16451. set normalBias(normalBias: number);
  16452. protected _blurBoxOffset: number;
  16453. /**
  16454. * Gets the blur box offset: offset applied during the blur pass.
  16455. * Only useful if useKernelBlur = false
  16456. */
  16457. get blurBoxOffset(): number;
  16458. /**
  16459. * Sets the blur box offset: offset applied during the blur pass.
  16460. * Only useful if useKernelBlur = false
  16461. */
  16462. set blurBoxOffset(value: number);
  16463. protected _blurScale: number;
  16464. /**
  16465. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16466. * 2 means half of the size.
  16467. */
  16468. get blurScale(): number;
  16469. /**
  16470. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16471. * 2 means half of the size.
  16472. */
  16473. set blurScale(value: number);
  16474. protected _blurKernel: number;
  16475. /**
  16476. * Gets the blur kernel: kernel size of the blur pass.
  16477. * Only useful if useKernelBlur = true
  16478. */
  16479. get blurKernel(): number;
  16480. /**
  16481. * Sets the blur kernel: kernel size of the blur pass.
  16482. * Only useful if useKernelBlur = true
  16483. */
  16484. set blurKernel(value: number);
  16485. protected _useKernelBlur: boolean;
  16486. /**
  16487. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16488. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16489. */
  16490. get useKernelBlur(): boolean;
  16491. /**
  16492. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16493. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16494. */
  16495. set useKernelBlur(value: boolean);
  16496. protected _depthScale: number;
  16497. /**
  16498. * Gets the depth scale used in ESM mode.
  16499. */
  16500. get depthScale(): number;
  16501. /**
  16502. * Sets the depth scale used in ESM mode.
  16503. * This can override the scale stored on the light.
  16504. */
  16505. set depthScale(value: number);
  16506. protected _validateFilter(filter: number): number;
  16507. protected _filter: number;
  16508. /**
  16509. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16510. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16511. */
  16512. get filter(): number;
  16513. /**
  16514. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16515. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16516. */
  16517. set filter(value: number);
  16518. /**
  16519. * Gets if the current filter is set to Poisson Sampling.
  16520. */
  16521. get usePoissonSampling(): boolean;
  16522. /**
  16523. * Sets the current filter to Poisson Sampling.
  16524. */
  16525. set usePoissonSampling(value: boolean);
  16526. /**
  16527. * Gets if the current filter is set to ESM.
  16528. */
  16529. get useExponentialShadowMap(): boolean;
  16530. /**
  16531. * Sets the current filter is to ESM.
  16532. */
  16533. set useExponentialShadowMap(value: boolean);
  16534. /**
  16535. * Gets if the current filter is set to filtered ESM.
  16536. */
  16537. get useBlurExponentialShadowMap(): boolean;
  16538. /**
  16539. * Gets if the current filter is set to filtered ESM.
  16540. */
  16541. set useBlurExponentialShadowMap(value: boolean);
  16542. /**
  16543. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16544. * exponential to prevent steep falloff artifacts).
  16545. */
  16546. get useCloseExponentialShadowMap(): boolean;
  16547. /**
  16548. * Sets the current filter to "close ESM" (using the inverse of the
  16549. * exponential to prevent steep falloff artifacts).
  16550. */
  16551. set useCloseExponentialShadowMap(value: boolean);
  16552. /**
  16553. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16554. * exponential to prevent steep falloff artifacts).
  16555. */
  16556. get useBlurCloseExponentialShadowMap(): boolean;
  16557. /**
  16558. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16559. * exponential to prevent steep falloff artifacts).
  16560. */
  16561. set useBlurCloseExponentialShadowMap(value: boolean);
  16562. /**
  16563. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16564. */
  16565. get usePercentageCloserFiltering(): boolean;
  16566. /**
  16567. * Sets the current filter to "PCF" (percentage closer filtering).
  16568. */
  16569. set usePercentageCloserFiltering(value: boolean);
  16570. protected _filteringQuality: number;
  16571. /**
  16572. * Gets the PCF or PCSS Quality.
  16573. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16574. */
  16575. get filteringQuality(): number;
  16576. /**
  16577. * Sets the PCF or PCSS Quality.
  16578. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16579. */
  16580. set filteringQuality(filteringQuality: number);
  16581. /**
  16582. * Gets if the current filter is set to "PCSS" (contact hardening).
  16583. */
  16584. get useContactHardeningShadow(): boolean;
  16585. /**
  16586. * Sets the current filter to "PCSS" (contact hardening).
  16587. */
  16588. set useContactHardeningShadow(value: boolean);
  16589. protected _contactHardeningLightSizeUVRatio: number;
  16590. /**
  16591. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16592. * Using a ratio helps keeping shape stability independently of the map size.
  16593. *
  16594. * It does not account for the light projection as it was having too much
  16595. * instability during the light setup or during light position changes.
  16596. *
  16597. * Only valid if useContactHardeningShadow is true.
  16598. */
  16599. get contactHardeningLightSizeUVRatio(): number;
  16600. /**
  16601. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16602. * Using a ratio helps keeping shape stability independently of the map size.
  16603. *
  16604. * It does not account for the light projection as it was having too much
  16605. * instability during the light setup or during light position changes.
  16606. *
  16607. * Only valid if useContactHardeningShadow is true.
  16608. */
  16609. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16610. protected _darkness: number;
  16611. /** Gets or sets the actual darkness of a shadow */
  16612. get darkness(): number;
  16613. set darkness(value: number);
  16614. /**
  16615. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16616. * 0 means strongest and 1 would means no shadow.
  16617. * @returns the darkness.
  16618. */
  16619. getDarkness(): number;
  16620. /**
  16621. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16622. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16623. * @returns the shadow generator allowing fluent coding.
  16624. */
  16625. setDarkness(darkness: number): ShadowGenerator;
  16626. protected _transparencyShadow: boolean;
  16627. /** Gets or sets the ability to have transparent shadow */
  16628. get transparencyShadow(): boolean;
  16629. set transparencyShadow(value: boolean);
  16630. /**
  16631. * Sets the ability to have transparent shadow (boolean).
  16632. * @param transparent True if transparent else False
  16633. * @returns the shadow generator allowing fluent coding
  16634. */
  16635. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16636. protected _shadowMap: Nullable<RenderTargetTexture>;
  16637. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16638. /**
  16639. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16640. * @returns The render target texture if present otherwise, null
  16641. */
  16642. getShadowMap(): Nullable<RenderTargetTexture>;
  16643. /**
  16644. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16645. * @returns The render target texture if the shadow map is present otherwise, null
  16646. */
  16647. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16648. /**
  16649. * Gets the class name of that object
  16650. * @returns "ShadowGenerator"
  16651. */
  16652. getClassName(): string;
  16653. /**
  16654. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16655. * @param mesh Mesh to add
  16656. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16657. * @returns the Shadow Generator itself
  16658. */
  16659. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16660. /**
  16661. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16662. * @param mesh Mesh to remove
  16663. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16664. * @returns the Shadow Generator itself
  16665. */
  16666. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16667. /**
  16668. * Controls the extent to which the shadows fade out at the edge of the frustum
  16669. */
  16670. frustumEdgeFalloff: number;
  16671. protected _light: IShadowLight;
  16672. /**
  16673. * Returns the associated light object.
  16674. * @returns the light generating the shadow
  16675. */
  16676. getLight(): IShadowLight;
  16677. /**
  16678. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16679. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16680. * It might on the other hand introduce peter panning.
  16681. */
  16682. forceBackFacesOnly: boolean;
  16683. protected _scene: Scene;
  16684. protected _lightDirection: Vector3;
  16685. protected _effect: Effect;
  16686. protected _viewMatrix: Matrix;
  16687. protected _projectionMatrix: Matrix;
  16688. protected _transformMatrix: Matrix;
  16689. protected _cachedPosition: Vector3;
  16690. protected _cachedDirection: Vector3;
  16691. protected _cachedDefines: string;
  16692. protected _currentRenderID: number;
  16693. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16694. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16695. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16696. protected _blurPostProcesses: PostProcess[];
  16697. protected _mapSize: number;
  16698. protected _currentFaceIndex: number;
  16699. protected _currentFaceIndexCache: number;
  16700. protected _textureType: number;
  16701. protected _defaultTextureMatrix: Matrix;
  16702. protected _storedUniqueId: Nullable<number>;
  16703. /** @hidden */
  16704. static _SceneComponentInitialization: (scene: Scene) => void;
  16705. /**
  16706. * Creates a ShadowGenerator object.
  16707. * A ShadowGenerator is the required tool to use the shadows.
  16708. * Each light casting shadows needs to use its own ShadowGenerator.
  16709. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16710. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16711. * @param light The light object generating the shadows.
  16712. * @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.
  16713. */
  16714. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16715. protected _initializeGenerator(): void;
  16716. protected _createTargetRenderTexture(): void;
  16717. protected _initializeShadowMap(): void;
  16718. protected _initializeBlurRTTAndPostProcesses(): void;
  16719. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16720. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16721. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16722. protected _applyFilterValues(): void;
  16723. /**
  16724. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16725. * @param onCompiled Callback triggered at the and of the effects compilation
  16726. * @param options Sets of optional options forcing the compilation with different modes
  16727. */
  16728. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16729. useInstances: boolean;
  16730. }>): void;
  16731. /**
  16732. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16733. * @param options Sets of optional options forcing the compilation with different modes
  16734. * @returns A promise that resolves when the compilation completes
  16735. */
  16736. forceCompilationAsync(options?: Partial<{
  16737. useInstances: boolean;
  16738. }>): Promise<void>;
  16739. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16740. /**
  16741. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16742. * @param subMesh The submesh we want to render in the shadow map
  16743. * @param useInstances Defines wether will draw in the map using instances
  16744. * @returns true if ready otherwise, false
  16745. */
  16746. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16747. /**
  16748. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16749. * @param defines Defines of the material we want to update
  16750. * @param lightIndex Index of the light in the enabled light list of the material
  16751. */
  16752. prepareDefines(defines: any, lightIndex: number): void;
  16753. /**
  16754. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16755. * defined in the generator but impacting the effect).
  16756. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16757. * @param effect The effect we are binfing the information for
  16758. */
  16759. bindShadowLight(lightIndex: string, effect: Effect): void;
  16760. /**
  16761. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16762. * (eq to shadow prjection matrix * light transform matrix)
  16763. * @returns The transform matrix used to create the shadow map
  16764. */
  16765. getTransformMatrix(): Matrix;
  16766. /**
  16767. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16768. * Cube and 2D textures for instance.
  16769. */
  16770. recreateShadowMap(): void;
  16771. protected _disposeBlurPostProcesses(): void;
  16772. protected _disposeRTTandPostProcesses(): void;
  16773. /**
  16774. * Disposes the ShadowGenerator.
  16775. * Returns nothing.
  16776. */
  16777. dispose(): void;
  16778. /**
  16779. * Serializes the shadow generator setup to a json object.
  16780. * @returns The serialized JSON object
  16781. */
  16782. serialize(): any;
  16783. /**
  16784. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16785. * @param parsedShadowGenerator The JSON object to parse
  16786. * @param scene The scene to create the shadow map for
  16787. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16788. * @returns The parsed shadow generator
  16789. */
  16790. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16791. }
  16792. }
  16793. declare module BABYLON {
  16794. /**
  16795. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16796. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16797. * 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.
  16798. */
  16799. export abstract class Light extends Node {
  16800. /**
  16801. * Falloff Default: light is falling off following the material specification:
  16802. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16803. */
  16804. static readonly FALLOFF_DEFAULT: number;
  16805. /**
  16806. * Falloff Physical: light is falling off following the inverse squared distance law.
  16807. */
  16808. static readonly FALLOFF_PHYSICAL: number;
  16809. /**
  16810. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16811. * to enhance interoperability with other engines.
  16812. */
  16813. static readonly FALLOFF_GLTF: number;
  16814. /**
  16815. * Falloff Standard: light is falling off like in the standard material
  16816. * to enhance interoperability with other materials.
  16817. */
  16818. static readonly FALLOFF_STANDARD: number;
  16819. /**
  16820. * If every light affecting the material is in this lightmapMode,
  16821. * material.lightmapTexture adds or multiplies
  16822. * (depends on material.useLightmapAsShadowmap)
  16823. * after every other light calculations.
  16824. */
  16825. static readonly LIGHTMAP_DEFAULT: number;
  16826. /**
  16827. * material.lightmapTexture as only diffuse lighting from this light
  16828. * adds only specular lighting from this light
  16829. * adds dynamic shadows
  16830. */
  16831. static readonly LIGHTMAP_SPECULAR: number;
  16832. /**
  16833. * material.lightmapTexture as only lighting
  16834. * no light calculation from this light
  16835. * only adds dynamic shadows from this light
  16836. */
  16837. static readonly LIGHTMAP_SHADOWSONLY: number;
  16838. /**
  16839. * Each light type uses the default quantity according to its type:
  16840. * point/spot lights use luminous intensity
  16841. * directional lights use illuminance
  16842. */
  16843. static readonly INTENSITYMODE_AUTOMATIC: number;
  16844. /**
  16845. * lumen (lm)
  16846. */
  16847. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16848. /**
  16849. * candela (lm/sr)
  16850. */
  16851. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16852. /**
  16853. * lux (lm/m^2)
  16854. */
  16855. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16856. /**
  16857. * nit (cd/m^2)
  16858. */
  16859. static readonly INTENSITYMODE_LUMINANCE: number;
  16860. /**
  16861. * Light type const id of the point light.
  16862. */
  16863. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16864. /**
  16865. * Light type const id of the directional light.
  16866. */
  16867. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16868. /**
  16869. * Light type const id of the spot light.
  16870. */
  16871. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16872. /**
  16873. * Light type const id of the hemispheric light.
  16874. */
  16875. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16876. /**
  16877. * Diffuse gives the basic color to an object.
  16878. */
  16879. diffuse: Color3;
  16880. /**
  16881. * Specular produces a highlight color on an object.
  16882. * Note: This is note affecting PBR materials.
  16883. */
  16884. specular: Color3;
  16885. /**
  16886. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16887. * falling off base on range or angle.
  16888. * This can be set to any values in Light.FALLOFF_x.
  16889. *
  16890. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16891. * other types of materials.
  16892. */
  16893. falloffType: number;
  16894. /**
  16895. * Strength of the light.
  16896. * Note: By default it is define in the framework own unit.
  16897. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16898. */
  16899. intensity: number;
  16900. private _range;
  16901. protected _inverseSquaredRange: number;
  16902. /**
  16903. * Defines how far from the source the light is impacting in scene units.
  16904. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16905. */
  16906. get range(): number;
  16907. /**
  16908. * Defines how far from the source the light is impacting in scene units.
  16909. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16910. */
  16911. set range(value: number);
  16912. /**
  16913. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16914. * of light.
  16915. */
  16916. private _photometricScale;
  16917. private _intensityMode;
  16918. /**
  16919. * Gets the photometric scale used to interpret the intensity.
  16920. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16921. */
  16922. get intensityMode(): number;
  16923. /**
  16924. * Sets the photometric scale used to interpret the intensity.
  16925. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16926. */
  16927. set intensityMode(value: number);
  16928. private _radius;
  16929. /**
  16930. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16931. */
  16932. get radius(): number;
  16933. /**
  16934. * sets the light radius used by PBR Materials to simulate soft area lights.
  16935. */
  16936. set radius(value: number);
  16937. private _renderPriority;
  16938. /**
  16939. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16940. * exceeding the number allowed of the materials.
  16941. */
  16942. renderPriority: number;
  16943. private _shadowEnabled;
  16944. /**
  16945. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16946. * the current shadow generator.
  16947. */
  16948. get shadowEnabled(): boolean;
  16949. /**
  16950. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16951. * the current shadow generator.
  16952. */
  16953. set shadowEnabled(value: boolean);
  16954. private _includedOnlyMeshes;
  16955. /**
  16956. * Gets the only meshes impacted by this light.
  16957. */
  16958. get includedOnlyMeshes(): AbstractMesh[];
  16959. /**
  16960. * Sets the only meshes impacted by this light.
  16961. */
  16962. set includedOnlyMeshes(value: AbstractMesh[]);
  16963. private _excludedMeshes;
  16964. /**
  16965. * Gets the meshes not impacted by this light.
  16966. */
  16967. get excludedMeshes(): AbstractMesh[];
  16968. /**
  16969. * Sets the meshes not impacted by this light.
  16970. */
  16971. set excludedMeshes(value: AbstractMesh[]);
  16972. private _excludeWithLayerMask;
  16973. /**
  16974. * Gets the layer id use to find what meshes are not impacted by the light.
  16975. * Inactive if 0
  16976. */
  16977. get excludeWithLayerMask(): number;
  16978. /**
  16979. * Sets the layer id use to find what meshes are not impacted by the light.
  16980. * Inactive if 0
  16981. */
  16982. set excludeWithLayerMask(value: number);
  16983. private _includeOnlyWithLayerMask;
  16984. /**
  16985. * Gets the layer id use to find what meshes are impacted by the light.
  16986. * Inactive if 0
  16987. */
  16988. get includeOnlyWithLayerMask(): number;
  16989. /**
  16990. * Sets the layer id use to find what meshes are impacted by the light.
  16991. * Inactive if 0
  16992. */
  16993. set includeOnlyWithLayerMask(value: number);
  16994. private _lightmapMode;
  16995. /**
  16996. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16997. */
  16998. get lightmapMode(): number;
  16999. /**
  17000. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17001. */
  17002. set lightmapMode(value: number);
  17003. /**
  17004. * Shadow generator associted to the light.
  17005. * @hidden Internal use only.
  17006. */
  17007. _shadowGenerator: Nullable<IShadowGenerator>;
  17008. /**
  17009. * @hidden Internal use only.
  17010. */
  17011. _excludedMeshesIds: string[];
  17012. /**
  17013. * @hidden Internal use only.
  17014. */
  17015. _includedOnlyMeshesIds: string[];
  17016. /**
  17017. * The current light unifom buffer.
  17018. * @hidden Internal use only.
  17019. */
  17020. _uniformBuffer: UniformBuffer;
  17021. /** @hidden */
  17022. _renderId: number;
  17023. /**
  17024. * Creates a Light object in the scene.
  17025. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17026. * @param name The firendly name of the light
  17027. * @param scene The scene the light belongs too
  17028. */
  17029. constructor(name: string, scene: Scene);
  17030. protected abstract _buildUniformLayout(): void;
  17031. /**
  17032. * Sets the passed Effect "effect" with the Light information.
  17033. * @param effect The effect to update
  17034. * @param lightIndex The index of the light in the effect to update
  17035. * @returns The light
  17036. */
  17037. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17038. /**
  17039. * Sets the passed Effect "effect" with the Light textures.
  17040. * @param effect The effect to update
  17041. * @param lightIndex The index of the light in the effect to update
  17042. * @returns The light
  17043. */
  17044. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17045. /**
  17046. * Binds the lights information from the scene to the effect for the given mesh.
  17047. * @param lightIndex Light index
  17048. * @param scene The scene where the light belongs to
  17049. * @param effect The effect we are binding the data to
  17050. * @param useSpecular Defines if specular is supported
  17051. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17052. */
  17053. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17054. /**
  17055. * Sets the passed Effect "effect" with the Light information.
  17056. * @param effect The effect to update
  17057. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17058. * @returns The light
  17059. */
  17060. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17061. /**
  17062. * Returns the string "Light".
  17063. * @returns the class name
  17064. */
  17065. getClassName(): string;
  17066. /** @hidden */
  17067. readonly _isLight: boolean;
  17068. /**
  17069. * Converts the light information to a readable string for debug purpose.
  17070. * @param fullDetails Supports for multiple levels of logging within scene loading
  17071. * @returns the human readable light info
  17072. */
  17073. toString(fullDetails?: boolean): string;
  17074. /** @hidden */
  17075. protected _syncParentEnabledState(): void;
  17076. /**
  17077. * Set the enabled state of this node.
  17078. * @param value - the new enabled state
  17079. */
  17080. setEnabled(value: boolean): void;
  17081. /**
  17082. * Returns the Light associated shadow generator if any.
  17083. * @return the associated shadow generator.
  17084. */
  17085. getShadowGenerator(): Nullable<IShadowGenerator>;
  17086. /**
  17087. * Returns a Vector3, the absolute light position in the World.
  17088. * @returns the world space position of the light
  17089. */
  17090. getAbsolutePosition(): Vector3;
  17091. /**
  17092. * Specifies if the light will affect the passed mesh.
  17093. * @param mesh The mesh to test against the light
  17094. * @return true the mesh is affected otherwise, false.
  17095. */
  17096. canAffectMesh(mesh: AbstractMesh): boolean;
  17097. /**
  17098. * Sort function to order lights for rendering.
  17099. * @param a First Light object to compare to second.
  17100. * @param b Second Light object to compare first.
  17101. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17102. */
  17103. static CompareLightsPriority(a: Light, b: Light): number;
  17104. /**
  17105. * Releases resources associated with this node.
  17106. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17107. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17108. */
  17109. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17110. /**
  17111. * Returns the light type ID (integer).
  17112. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17113. */
  17114. getTypeID(): number;
  17115. /**
  17116. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17117. * @returns the scaled intensity in intensity mode unit
  17118. */
  17119. getScaledIntensity(): number;
  17120. /**
  17121. * Returns a new Light object, named "name", from the current one.
  17122. * @param name The name of the cloned light
  17123. * @returns the new created light
  17124. */
  17125. clone(name: string): Nullable<Light>;
  17126. /**
  17127. * Serializes the current light into a Serialization object.
  17128. * @returns the serialized object.
  17129. */
  17130. serialize(): any;
  17131. /**
  17132. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17133. * This new light is named "name" and added to the passed scene.
  17134. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17135. * @param name The friendly name of the light
  17136. * @param scene The scene the new light will belong to
  17137. * @returns the constructor function
  17138. */
  17139. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17140. /**
  17141. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17142. * @param parsedLight The JSON representation of the light
  17143. * @param scene The scene to create the parsed light in
  17144. * @returns the created light after parsing
  17145. */
  17146. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17147. private _hookArrayForExcluded;
  17148. private _hookArrayForIncludedOnly;
  17149. private _resyncMeshes;
  17150. /**
  17151. * Forces the meshes to update their light related information in their rendering used effects
  17152. * @hidden Internal Use Only
  17153. */
  17154. _markMeshesAsLightDirty(): void;
  17155. /**
  17156. * Recomputes the cached photometric scale if needed.
  17157. */
  17158. private _computePhotometricScale;
  17159. /**
  17160. * Returns the Photometric Scale according to the light type and intensity mode.
  17161. */
  17162. private _getPhotometricScale;
  17163. /**
  17164. * Reorder the light in the scene according to their defined priority.
  17165. * @hidden Internal Use Only
  17166. */
  17167. _reorderLightsInScene(): void;
  17168. /**
  17169. * Prepares the list of defines specific to the light type.
  17170. * @param defines the list of defines
  17171. * @param lightIndex defines the index of the light for the effect
  17172. */
  17173. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17174. }
  17175. }
  17176. declare module BABYLON {
  17177. /**
  17178. * Interface used to define Action
  17179. */
  17180. export interface IAction {
  17181. /**
  17182. * Trigger for the action
  17183. */
  17184. trigger: number;
  17185. /** Options of the trigger */
  17186. triggerOptions: any;
  17187. /**
  17188. * Gets the trigger parameters
  17189. * @returns the trigger parameters
  17190. */
  17191. getTriggerParameter(): any;
  17192. /**
  17193. * Internal only - executes current action event
  17194. * @hidden
  17195. */
  17196. _executeCurrent(evt?: ActionEvent): void;
  17197. /**
  17198. * Serialize placeholder for child classes
  17199. * @param parent of child
  17200. * @returns the serialized object
  17201. */
  17202. serialize(parent: any): any;
  17203. /**
  17204. * Internal only
  17205. * @hidden
  17206. */
  17207. _prepare(): void;
  17208. /**
  17209. * Internal only - manager for action
  17210. * @hidden
  17211. */
  17212. _actionManager: AbstractActionManager;
  17213. /**
  17214. * Adds action to chain of actions, may be a DoNothingAction
  17215. * @param action defines the next action to execute
  17216. * @returns The action passed in
  17217. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17218. */
  17219. then(action: IAction): IAction;
  17220. }
  17221. /**
  17222. * The action to be carried out following a trigger
  17223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17224. */
  17225. export class Action implements IAction {
  17226. /** the trigger, with or without parameters, for the action */
  17227. triggerOptions: any;
  17228. /**
  17229. * Trigger for the action
  17230. */
  17231. trigger: number;
  17232. /**
  17233. * Internal only - manager for action
  17234. * @hidden
  17235. */
  17236. _actionManager: ActionManager;
  17237. private _nextActiveAction;
  17238. private _child;
  17239. private _condition?;
  17240. private _triggerParameter;
  17241. /**
  17242. * An event triggered prior to action being executed.
  17243. */
  17244. onBeforeExecuteObservable: Observable<Action>;
  17245. /**
  17246. * Creates a new Action
  17247. * @param triggerOptions the trigger, with or without parameters, for the action
  17248. * @param condition an optional determinant of action
  17249. */
  17250. constructor(
  17251. /** the trigger, with or without parameters, for the action */
  17252. triggerOptions: any, condition?: Condition);
  17253. /**
  17254. * Internal only
  17255. * @hidden
  17256. */
  17257. _prepare(): void;
  17258. /**
  17259. * Gets the trigger parameters
  17260. * @returns the trigger parameters
  17261. */
  17262. getTriggerParameter(): any;
  17263. /**
  17264. * Internal only - executes current action event
  17265. * @hidden
  17266. */
  17267. _executeCurrent(evt?: ActionEvent): void;
  17268. /**
  17269. * Execute placeholder for child classes
  17270. * @param evt optional action event
  17271. */
  17272. execute(evt?: ActionEvent): void;
  17273. /**
  17274. * Skips to next active action
  17275. */
  17276. skipToNextActiveAction(): void;
  17277. /**
  17278. * Adds action to chain of actions, may be a DoNothingAction
  17279. * @param action defines the next action to execute
  17280. * @returns The action passed in
  17281. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17282. */
  17283. then(action: Action): Action;
  17284. /**
  17285. * Internal only
  17286. * @hidden
  17287. */
  17288. _getProperty(propertyPath: string): string;
  17289. /**
  17290. * Internal only
  17291. * @hidden
  17292. */
  17293. _getEffectiveTarget(target: any, propertyPath: string): any;
  17294. /**
  17295. * Serialize placeholder for child classes
  17296. * @param parent of child
  17297. * @returns the serialized object
  17298. */
  17299. serialize(parent: any): any;
  17300. /**
  17301. * Internal only called by serialize
  17302. * @hidden
  17303. */
  17304. protected _serialize(serializedAction: any, parent?: any): any;
  17305. /**
  17306. * Internal only
  17307. * @hidden
  17308. */
  17309. static _SerializeValueAsString: (value: any) => string;
  17310. /**
  17311. * Internal only
  17312. * @hidden
  17313. */
  17314. static _GetTargetProperty: (target: Node | Scene) => {
  17315. name: string;
  17316. targetType: string;
  17317. value: string;
  17318. };
  17319. }
  17320. }
  17321. declare module BABYLON {
  17322. /**
  17323. * A Condition applied to an Action
  17324. */
  17325. export class Condition {
  17326. /**
  17327. * Internal only - manager for action
  17328. * @hidden
  17329. */
  17330. _actionManager: ActionManager;
  17331. /**
  17332. * Internal only
  17333. * @hidden
  17334. */
  17335. _evaluationId: number;
  17336. /**
  17337. * Internal only
  17338. * @hidden
  17339. */
  17340. _currentResult: boolean;
  17341. /**
  17342. * Creates a new Condition
  17343. * @param actionManager the manager of the action the condition is applied to
  17344. */
  17345. constructor(actionManager: ActionManager);
  17346. /**
  17347. * Check if the current condition is valid
  17348. * @returns a boolean
  17349. */
  17350. isValid(): boolean;
  17351. /**
  17352. * Internal only
  17353. * @hidden
  17354. */
  17355. _getProperty(propertyPath: string): string;
  17356. /**
  17357. * Internal only
  17358. * @hidden
  17359. */
  17360. _getEffectiveTarget(target: any, propertyPath: string): any;
  17361. /**
  17362. * Serialize placeholder for child classes
  17363. * @returns the serialized object
  17364. */
  17365. serialize(): any;
  17366. /**
  17367. * Internal only
  17368. * @hidden
  17369. */
  17370. protected _serialize(serializedCondition: any): any;
  17371. }
  17372. /**
  17373. * Defines specific conditional operators as extensions of Condition
  17374. */
  17375. export class ValueCondition extends Condition {
  17376. /** path to specify the property of the target the conditional operator uses */
  17377. propertyPath: string;
  17378. /** the value compared by the conditional operator against the current value of the property */
  17379. value: any;
  17380. /** the conditional operator, default ValueCondition.IsEqual */
  17381. operator: number;
  17382. /**
  17383. * Internal only
  17384. * @hidden
  17385. */
  17386. private static _IsEqual;
  17387. /**
  17388. * Internal only
  17389. * @hidden
  17390. */
  17391. private static _IsDifferent;
  17392. /**
  17393. * Internal only
  17394. * @hidden
  17395. */
  17396. private static _IsGreater;
  17397. /**
  17398. * Internal only
  17399. * @hidden
  17400. */
  17401. private static _IsLesser;
  17402. /**
  17403. * returns the number for IsEqual
  17404. */
  17405. static get IsEqual(): number;
  17406. /**
  17407. * Returns the number for IsDifferent
  17408. */
  17409. static get IsDifferent(): number;
  17410. /**
  17411. * Returns the number for IsGreater
  17412. */
  17413. static get IsGreater(): number;
  17414. /**
  17415. * Returns the number for IsLesser
  17416. */
  17417. static get IsLesser(): number;
  17418. /**
  17419. * Internal only The action manager for the condition
  17420. * @hidden
  17421. */
  17422. _actionManager: ActionManager;
  17423. /**
  17424. * Internal only
  17425. * @hidden
  17426. */
  17427. private _target;
  17428. /**
  17429. * Internal only
  17430. * @hidden
  17431. */
  17432. private _effectiveTarget;
  17433. /**
  17434. * Internal only
  17435. * @hidden
  17436. */
  17437. private _property;
  17438. /**
  17439. * Creates a new ValueCondition
  17440. * @param actionManager manager for the action the condition applies to
  17441. * @param target for the action
  17442. * @param propertyPath path to specify the property of the target the conditional operator uses
  17443. * @param value the value compared by the conditional operator against the current value of the property
  17444. * @param operator the conditional operator, default ValueCondition.IsEqual
  17445. */
  17446. constructor(actionManager: ActionManager, target: any,
  17447. /** path to specify the property of the target the conditional operator uses */
  17448. propertyPath: string,
  17449. /** the value compared by the conditional operator against the current value of the property */
  17450. value: any,
  17451. /** the conditional operator, default ValueCondition.IsEqual */
  17452. operator?: number);
  17453. /**
  17454. * Compares the given value with the property value for the specified conditional operator
  17455. * @returns the result of the comparison
  17456. */
  17457. isValid(): boolean;
  17458. /**
  17459. * Serialize the ValueCondition into a JSON compatible object
  17460. * @returns serialization object
  17461. */
  17462. serialize(): any;
  17463. /**
  17464. * Gets the name of the conditional operator for the ValueCondition
  17465. * @param operator the conditional operator
  17466. * @returns the name
  17467. */
  17468. static GetOperatorName(operator: number): string;
  17469. }
  17470. /**
  17471. * Defines a predicate condition as an extension of Condition
  17472. */
  17473. export class PredicateCondition extends Condition {
  17474. /** defines the predicate function used to validate the condition */
  17475. predicate: () => boolean;
  17476. /**
  17477. * Internal only - manager for action
  17478. * @hidden
  17479. */
  17480. _actionManager: ActionManager;
  17481. /**
  17482. * Creates a new PredicateCondition
  17483. * @param actionManager manager for the action the condition applies to
  17484. * @param predicate defines the predicate function used to validate the condition
  17485. */
  17486. constructor(actionManager: ActionManager,
  17487. /** defines the predicate function used to validate the condition */
  17488. predicate: () => boolean);
  17489. /**
  17490. * @returns the validity of the predicate condition
  17491. */
  17492. isValid(): boolean;
  17493. }
  17494. /**
  17495. * Defines a state condition as an extension of Condition
  17496. */
  17497. export class StateCondition extends Condition {
  17498. /** Value to compare with target state */
  17499. value: string;
  17500. /**
  17501. * Internal only - manager for action
  17502. * @hidden
  17503. */
  17504. _actionManager: ActionManager;
  17505. /**
  17506. * Internal only
  17507. * @hidden
  17508. */
  17509. private _target;
  17510. /**
  17511. * Creates a new StateCondition
  17512. * @param actionManager manager for the action the condition applies to
  17513. * @param target of the condition
  17514. * @param value to compare with target state
  17515. */
  17516. constructor(actionManager: ActionManager, target: any,
  17517. /** Value to compare with target state */
  17518. value: string);
  17519. /**
  17520. * Gets a boolean indicating if the current condition is met
  17521. * @returns the validity of the state
  17522. */
  17523. isValid(): boolean;
  17524. /**
  17525. * Serialize the StateCondition into a JSON compatible object
  17526. * @returns serialization object
  17527. */
  17528. serialize(): any;
  17529. }
  17530. }
  17531. declare module BABYLON {
  17532. /**
  17533. * This defines an action responsible to toggle a boolean once triggered.
  17534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17535. */
  17536. export class SwitchBooleanAction extends Action {
  17537. /**
  17538. * The path to the boolean property in the target object
  17539. */
  17540. propertyPath: string;
  17541. private _target;
  17542. private _effectiveTarget;
  17543. private _property;
  17544. /**
  17545. * Instantiate the action
  17546. * @param triggerOptions defines the trigger options
  17547. * @param target defines the object containing the boolean
  17548. * @param propertyPath defines the path to the boolean property in the target object
  17549. * @param condition defines the trigger related conditions
  17550. */
  17551. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17552. /** @hidden */
  17553. _prepare(): void;
  17554. /**
  17555. * Execute the action toggle the boolean value.
  17556. */
  17557. execute(): void;
  17558. /**
  17559. * Serializes the actions and its related information.
  17560. * @param parent defines the object to serialize in
  17561. * @returns the serialized object
  17562. */
  17563. serialize(parent: any): any;
  17564. }
  17565. /**
  17566. * This defines an action responsible to set a the state field of the target
  17567. * to a desired value once triggered.
  17568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17569. */
  17570. export class SetStateAction extends Action {
  17571. /**
  17572. * The value to store in the state field.
  17573. */
  17574. value: string;
  17575. private _target;
  17576. /**
  17577. * Instantiate the action
  17578. * @param triggerOptions defines the trigger options
  17579. * @param target defines the object containing the state property
  17580. * @param value defines the value to store in the state field
  17581. * @param condition defines the trigger related conditions
  17582. */
  17583. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17584. /**
  17585. * Execute the action and store the value on the target state property.
  17586. */
  17587. execute(): void;
  17588. /**
  17589. * Serializes the actions and its related information.
  17590. * @param parent defines the object to serialize in
  17591. * @returns the serialized object
  17592. */
  17593. serialize(parent: any): any;
  17594. }
  17595. /**
  17596. * This defines an action responsible to set a property of the target
  17597. * to a desired value once triggered.
  17598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17599. */
  17600. export class SetValueAction extends Action {
  17601. /**
  17602. * The path of the property to set in the target.
  17603. */
  17604. propertyPath: string;
  17605. /**
  17606. * The value to set in the property
  17607. */
  17608. value: any;
  17609. private _target;
  17610. private _effectiveTarget;
  17611. private _property;
  17612. /**
  17613. * Instantiate the action
  17614. * @param triggerOptions defines the trigger options
  17615. * @param target defines the object containing the property
  17616. * @param propertyPath defines the path of the property to set in the target
  17617. * @param value defines the value to set in the property
  17618. * @param condition defines the trigger related conditions
  17619. */
  17620. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17621. /** @hidden */
  17622. _prepare(): void;
  17623. /**
  17624. * Execute the action and set the targetted property to the desired value.
  17625. */
  17626. execute(): void;
  17627. /**
  17628. * Serializes the actions and its related information.
  17629. * @param parent defines the object to serialize in
  17630. * @returns the serialized object
  17631. */
  17632. serialize(parent: any): any;
  17633. }
  17634. /**
  17635. * This defines an action responsible to increment the target value
  17636. * to a desired value once triggered.
  17637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17638. */
  17639. export class IncrementValueAction extends Action {
  17640. /**
  17641. * The path of the property to increment in the target.
  17642. */
  17643. propertyPath: string;
  17644. /**
  17645. * The value we should increment the property by.
  17646. */
  17647. value: any;
  17648. private _target;
  17649. private _effectiveTarget;
  17650. private _property;
  17651. /**
  17652. * Instantiate the action
  17653. * @param triggerOptions defines the trigger options
  17654. * @param target defines the object containing the property
  17655. * @param propertyPath defines the path of the property to increment in the target
  17656. * @param value defines the value value we should increment the property by
  17657. * @param condition defines the trigger related conditions
  17658. */
  17659. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17660. /** @hidden */
  17661. _prepare(): void;
  17662. /**
  17663. * Execute the action and increment the target of the value amount.
  17664. */
  17665. execute(): void;
  17666. /**
  17667. * Serializes the actions and its related information.
  17668. * @param parent defines the object to serialize in
  17669. * @returns the serialized object
  17670. */
  17671. serialize(parent: any): any;
  17672. }
  17673. /**
  17674. * This defines an action responsible to start an animation once triggered.
  17675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17676. */
  17677. export class PlayAnimationAction extends Action {
  17678. /**
  17679. * Where the animation should start (animation frame)
  17680. */
  17681. from: number;
  17682. /**
  17683. * Where the animation should stop (animation frame)
  17684. */
  17685. to: number;
  17686. /**
  17687. * Define if the animation should loop or stop after the first play.
  17688. */
  17689. loop?: boolean;
  17690. private _target;
  17691. /**
  17692. * Instantiate the action
  17693. * @param triggerOptions defines the trigger options
  17694. * @param target defines the target animation or animation name
  17695. * @param from defines from where the animation should start (animation frame)
  17696. * @param end defines where the animation should stop (animation frame)
  17697. * @param loop defines if the animation should loop or stop after the first play
  17698. * @param condition defines the trigger related conditions
  17699. */
  17700. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17701. /** @hidden */
  17702. _prepare(): void;
  17703. /**
  17704. * Execute the action and play the animation.
  17705. */
  17706. execute(): void;
  17707. /**
  17708. * Serializes the actions and its related information.
  17709. * @param parent defines the object to serialize in
  17710. * @returns the serialized object
  17711. */
  17712. serialize(parent: any): any;
  17713. }
  17714. /**
  17715. * This defines an action responsible to stop an animation once triggered.
  17716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17717. */
  17718. export class StopAnimationAction extends Action {
  17719. private _target;
  17720. /**
  17721. * Instantiate the action
  17722. * @param triggerOptions defines the trigger options
  17723. * @param target defines the target animation or animation name
  17724. * @param condition defines the trigger related conditions
  17725. */
  17726. constructor(triggerOptions: any, target: any, condition?: Condition);
  17727. /** @hidden */
  17728. _prepare(): void;
  17729. /**
  17730. * Execute the action and stop the animation.
  17731. */
  17732. execute(): void;
  17733. /**
  17734. * Serializes the actions and its related information.
  17735. * @param parent defines the object to serialize in
  17736. * @returns the serialized object
  17737. */
  17738. serialize(parent: any): any;
  17739. }
  17740. /**
  17741. * This defines an action responsible that does nothing once triggered.
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17743. */
  17744. export class DoNothingAction extends Action {
  17745. /**
  17746. * Instantiate the action
  17747. * @param triggerOptions defines the trigger options
  17748. * @param condition defines the trigger related conditions
  17749. */
  17750. constructor(triggerOptions?: any, condition?: Condition);
  17751. /**
  17752. * Execute the action and do nothing.
  17753. */
  17754. execute(): void;
  17755. /**
  17756. * Serializes the actions and its related information.
  17757. * @param parent defines the object to serialize in
  17758. * @returns the serialized object
  17759. */
  17760. serialize(parent: any): any;
  17761. }
  17762. /**
  17763. * This defines an action responsible to trigger several actions once triggered.
  17764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17765. */
  17766. export class CombineAction extends Action {
  17767. /**
  17768. * The list of aggregated animations to run.
  17769. */
  17770. children: Action[];
  17771. /**
  17772. * Instantiate the action
  17773. * @param triggerOptions defines the trigger options
  17774. * @param children defines the list of aggregated animations to run
  17775. * @param condition defines the trigger related conditions
  17776. */
  17777. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17778. /** @hidden */
  17779. _prepare(): void;
  17780. /**
  17781. * Execute the action and executes all the aggregated actions.
  17782. */
  17783. execute(evt: ActionEvent): void;
  17784. /**
  17785. * Serializes the actions and its related information.
  17786. * @param parent defines the object to serialize in
  17787. * @returns the serialized object
  17788. */
  17789. serialize(parent: any): any;
  17790. }
  17791. /**
  17792. * This defines an action responsible to run code (external event) once triggered.
  17793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17794. */
  17795. export class ExecuteCodeAction extends Action {
  17796. /**
  17797. * The callback function to run.
  17798. */
  17799. func: (evt: ActionEvent) => void;
  17800. /**
  17801. * Instantiate the action
  17802. * @param triggerOptions defines the trigger options
  17803. * @param func defines the callback function to run
  17804. * @param condition defines the trigger related conditions
  17805. */
  17806. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17807. /**
  17808. * Execute the action and run the attached code.
  17809. */
  17810. execute(evt: ActionEvent): void;
  17811. }
  17812. /**
  17813. * This defines an action responsible to set the parent property of the target once triggered.
  17814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17815. */
  17816. export class SetParentAction extends Action {
  17817. private _parent;
  17818. private _target;
  17819. /**
  17820. * Instantiate the action
  17821. * @param triggerOptions defines the trigger options
  17822. * @param target defines the target containing the parent property
  17823. * @param parent defines from where the animation should start (animation frame)
  17824. * @param condition defines the trigger related conditions
  17825. */
  17826. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17827. /** @hidden */
  17828. _prepare(): void;
  17829. /**
  17830. * Execute the action and set the parent property.
  17831. */
  17832. execute(): void;
  17833. /**
  17834. * Serializes the actions and its related information.
  17835. * @param parent defines the object to serialize in
  17836. * @returns the serialized object
  17837. */
  17838. serialize(parent: any): any;
  17839. }
  17840. }
  17841. declare module BABYLON {
  17842. /**
  17843. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17844. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17846. */
  17847. export class ActionManager extends AbstractActionManager {
  17848. /**
  17849. * Nothing
  17850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17851. */
  17852. static readonly NothingTrigger: number;
  17853. /**
  17854. * On pick
  17855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17856. */
  17857. static readonly OnPickTrigger: number;
  17858. /**
  17859. * On left pick
  17860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17861. */
  17862. static readonly OnLeftPickTrigger: number;
  17863. /**
  17864. * On right pick
  17865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17866. */
  17867. static readonly OnRightPickTrigger: number;
  17868. /**
  17869. * On center pick
  17870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17871. */
  17872. static readonly OnCenterPickTrigger: number;
  17873. /**
  17874. * On pick down
  17875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17876. */
  17877. static readonly OnPickDownTrigger: number;
  17878. /**
  17879. * On double pick
  17880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17881. */
  17882. static readonly OnDoublePickTrigger: number;
  17883. /**
  17884. * On pick up
  17885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17886. */
  17887. static readonly OnPickUpTrigger: number;
  17888. /**
  17889. * On pick out.
  17890. * This trigger will only be raised if you also declared a OnPickDown
  17891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17892. */
  17893. static readonly OnPickOutTrigger: number;
  17894. /**
  17895. * On long press
  17896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17897. */
  17898. static readonly OnLongPressTrigger: number;
  17899. /**
  17900. * On pointer over
  17901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17902. */
  17903. static readonly OnPointerOverTrigger: number;
  17904. /**
  17905. * On pointer out
  17906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17907. */
  17908. static readonly OnPointerOutTrigger: number;
  17909. /**
  17910. * On every frame
  17911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17912. */
  17913. static readonly OnEveryFrameTrigger: number;
  17914. /**
  17915. * On intersection enter
  17916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17917. */
  17918. static readonly OnIntersectionEnterTrigger: number;
  17919. /**
  17920. * On intersection exit
  17921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17922. */
  17923. static readonly OnIntersectionExitTrigger: number;
  17924. /**
  17925. * On key down
  17926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17927. */
  17928. static readonly OnKeyDownTrigger: number;
  17929. /**
  17930. * On key up
  17931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17932. */
  17933. static readonly OnKeyUpTrigger: number;
  17934. private _scene;
  17935. /**
  17936. * Creates a new action manager
  17937. * @param scene defines the hosting scene
  17938. */
  17939. constructor(scene: Scene);
  17940. /**
  17941. * Releases all associated resources
  17942. */
  17943. dispose(): void;
  17944. /**
  17945. * Gets hosting scene
  17946. * @returns the hosting scene
  17947. */
  17948. getScene(): Scene;
  17949. /**
  17950. * Does this action manager handles actions of any of the given triggers
  17951. * @param triggers defines the triggers to be tested
  17952. * @return a boolean indicating whether one (or more) of the triggers is handled
  17953. */
  17954. hasSpecificTriggers(triggers: number[]): boolean;
  17955. /**
  17956. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17957. * speed.
  17958. * @param triggerA defines the trigger to be tested
  17959. * @param triggerB defines the trigger to be tested
  17960. * @return a boolean indicating whether one (or more) of the triggers is handled
  17961. */
  17962. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17963. /**
  17964. * Does this action manager handles actions of a given trigger
  17965. * @param trigger defines the trigger to be tested
  17966. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17967. * @return whether the trigger is handled
  17968. */
  17969. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17970. /**
  17971. * Does this action manager has pointer triggers
  17972. */
  17973. get hasPointerTriggers(): boolean;
  17974. /**
  17975. * Does this action manager has pick triggers
  17976. */
  17977. get hasPickTriggers(): boolean;
  17978. /**
  17979. * Registers an action to this action manager
  17980. * @param action defines the action to be registered
  17981. * @return the action amended (prepared) after registration
  17982. */
  17983. registerAction(action: IAction): Nullable<IAction>;
  17984. /**
  17985. * Unregisters an action to this action manager
  17986. * @param action defines the action to be unregistered
  17987. * @return a boolean indicating whether the action has been unregistered
  17988. */
  17989. unregisterAction(action: IAction): Boolean;
  17990. /**
  17991. * Process a specific trigger
  17992. * @param trigger defines the trigger to process
  17993. * @param evt defines the event details to be processed
  17994. */
  17995. processTrigger(trigger: number, evt?: IActionEvent): void;
  17996. /** @hidden */
  17997. _getEffectiveTarget(target: any, propertyPath: string): any;
  17998. /** @hidden */
  17999. _getProperty(propertyPath: string): string;
  18000. /**
  18001. * Serialize this manager to a JSON object
  18002. * @param name defines the property name to store this manager
  18003. * @returns a JSON representation of this manager
  18004. */
  18005. serialize(name: string): any;
  18006. /**
  18007. * Creates a new ActionManager from a JSON data
  18008. * @param parsedActions defines the JSON data to read from
  18009. * @param object defines the hosting mesh
  18010. * @param scene defines the hosting scene
  18011. */
  18012. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18013. /**
  18014. * Get a trigger name by index
  18015. * @param trigger defines the trigger index
  18016. * @returns a trigger name
  18017. */
  18018. static GetTriggerName(trigger: number): string;
  18019. }
  18020. }
  18021. declare module BABYLON {
  18022. /**
  18023. * Class used to represent a sprite
  18024. * @see http://doc.babylonjs.com/babylon101/sprites
  18025. */
  18026. export class Sprite {
  18027. /** defines the name */
  18028. name: string;
  18029. /** Gets or sets the current world position */
  18030. position: Vector3;
  18031. /** Gets or sets the main color */
  18032. color: Color4;
  18033. /** Gets or sets the width */
  18034. width: number;
  18035. /** Gets or sets the height */
  18036. height: number;
  18037. /** Gets or sets rotation angle */
  18038. angle: number;
  18039. /** Gets or sets the cell index in the sprite sheet */
  18040. cellIndex: number;
  18041. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18042. cellRef: string;
  18043. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18044. invertU: number;
  18045. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18046. invertV: number;
  18047. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18048. disposeWhenFinishedAnimating: boolean;
  18049. /** Gets the list of attached animations */
  18050. animations: Animation[];
  18051. /** Gets or sets a boolean indicating if the sprite can be picked */
  18052. isPickable: boolean;
  18053. /**
  18054. * Gets or sets the associated action manager
  18055. */
  18056. actionManager: Nullable<ActionManager>;
  18057. private _animationStarted;
  18058. private _loopAnimation;
  18059. private _fromIndex;
  18060. private _toIndex;
  18061. private _delay;
  18062. private _direction;
  18063. private _manager;
  18064. private _time;
  18065. private _onAnimationEnd;
  18066. /**
  18067. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18068. */
  18069. isVisible: boolean;
  18070. /**
  18071. * Gets or sets the sprite size
  18072. */
  18073. get size(): number;
  18074. set size(value: number);
  18075. /**
  18076. * Creates a new Sprite
  18077. * @param name defines the name
  18078. * @param manager defines the manager
  18079. */
  18080. constructor(
  18081. /** defines the name */
  18082. name: string, manager: ISpriteManager);
  18083. /**
  18084. * Starts an animation
  18085. * @param from defines the initial key
  18086. * @param to defines the end key
  18087. * @param loop defines if the animation must loop
  18088. * @param delay defines the start delay (in ms)
  18089. * @param onAnimationEnd defines a callback to call when animation ends
  18090. */
  18091. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18092. /** Stops current animation (if any) */
  18093. stopAnimation(): void;
  18094. /** @hidden */
  18095. _animate(deltaTime: number): void;
  18096. /** Release associated resources */
  18097. dispose(): void;
  18098. }
  18099. }
  18100. declare module BABYLON {
  18101. /**
  18102. * Information about the result of picking within a scene
  18103. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18104. */
  18105. export class PickingInfo {
  18106. /** @hidden */
  18107. _pickingUnavailable: boolean;
  18108. /**
  18109. * If the pick collided with an object
  18110. */
  18111. hit: boolean;
  18112. /**
  18113. * Distance away where the pick collided
  18114. */
  18115. distance: number;
  18116. /**
  18117. * The location of pick collision
  18118. */
  18119. pickedPoint: Nullable<Vector3>;
  18120. /**
  18121. * The mesh corresponding the the pick collision
  18122. */
  18123. pickedMesh: Nullable<AbstractMesh>;
  18124. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18125. bu: number;
  18126. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18127. bv: number;
  18128. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18129. faceId: number;
  18130. /** Id of the the submesh that was picked */
  18131. subMeshId: number;
  18132. /** If a sprite was picked, this will be the sprite the pick collided with */
  18133. pickedSprite: Nullable<Sprite>;
  18134. /**
  18135. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18136. */
  18137. originMesh: Nullable<AbstractMesh>;
  18138. /**
  18139. * The ray that was used to perform the picking.
  18140. */
  18141. ray: Nullable<Ray>;
  18142. /**
  18143. * Gets the normal correspodning to the face the pick collided with
  18144. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18145. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18146. * @returns The normal correspodning to the face the pick collided with
  18147. */
  18148. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18149. /**
  18150. * Gets the texture coordinates of where the pick occured
  18151. * @returns the vector containing the coordnates of the texture
  18152. */
  18153. getTextureCoordinates(): Nullable<Vector2>;
  18154. }
  18155. }
  18156. declare module BABYLON {
  18157. /**
  18158. * Gather the list of pointer event types as constants.
  18159. */
  18160. export class PointerEventTypes {
  18161. /**
  18162. * 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.
  18163. */
  18164. static readonly POINTERDOWN: number;
  18165. /**
  18166. * The pointerup event is fired when a pointer is no longer active.
  18167. */
  18168. static readonly POINTERUP: number;
  18169. /**
  18170. * The pointermove event is fired when a pointer changes coordinates.
  18171. */
  18172. static readonly POINTERMOVE: number;
  18173. /**
  18174. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18175. */
  18176. static readonly POINTERWHEEL: number;
  18177. /**
  18178. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18179. */
  18180. static readonly POINTERPICK: number;
  18181. /**
  18182. * The pointertap event is fired when a the object has been touched and released without drag.
  18183. */
  18184. static readonly POINTERTAP: number;
  18185. /**
  18186. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18187. */
  18188. static readonly POINTERDOUBLETAP: number;
  18189. }
  18190. /**
  18191. * Base class of pointer info types.
  18192. */
  18193. export class PointerInfoBase {
  18194. /**
  18195. * Defines the type of event (PointerEventTypes)
  18196. */
  18197. type: number;
  18198. /**
  18199. * Defines the related dom event
  18200. */
  18201. event: PointerEvent | MouseWheelEvent;
  18202. /**
  18203. * Instantiates the base class of pointers info.
  18204. * @param type Defines the type of event (PointerEventTypes)
  18205. * @param event Defines the related dom event
  18206. */
  18207. constructor(
  18208. /**
  18209. * Defines the type of event (PointerEventTypes)
  18210. */
  18211. type: number,
  18212. /**
  18213. * Defines the related dom event
  18214. */
  18215. event: PointerEvent | MouseWheelEvent);
  18216. }
  18217. /**
  18218. * This class is used to store pointer related info for the onPrePointerObservable event.
  18219. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18220. */
  18221. export class PointerInfoPre extends PointerInfoBase {
  18222. /**
  18223. * Ray from a pointer if availible (eg. 6dof controller)
  18224. */
  18225. ray: Nullable<Ray>;
  18226. /**
  18227. * Defines the local position of the pointer on the canvas.
  18228. */
  18229. localPosition: Vector2;
  18230. /**
  18231. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18232. */
  18233. skipOnPointerObservable: boolean;
  18234. /**
  18235. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18236. * @param type Defines the type of event (PointerEventTypes)
  18237. * @param event Defines the related dom event
  18238. * @param localX Defines the local x coordinates of the pointer when the event occured
  18239. * @param localY Defines the local y coordinates of the pointer when the event occured
  18240. */
  18241. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18242. }
  18243. /**
  18244. * This type contains all the data related to a pointer event in Babylon.js.
  18245. * 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.
  18246. */
  18247. export class PointerInfo extends PointerInfoBase {
  18248. /**
  18249. * Defines the picking info associated to the info (if any)\
  18250. */
  18251. pickInfo: Nullable<PickingInfo>;
  18252. /**
  18253. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18254. * @param type Defines the type of event (PointerEventTypes)
  18255. * @param event Defines the related dom event
  18256. * @param pickInfo Defines the picking info associated to the info (if any)\
  18257. */
  18258. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18259. /**
  18260. * Defines the picking info associated to the info (if any)\
  18261. */
  18262. pickInfo: Nullable<PickingInfo>);
  18263. }
  18264. /**
  18265. * Data relating to a touch event on the screen.
  18266. */
  18267. export interface PointerTouch {
  18268. /**
  18269. * X coordinate of touch.
  18270. */
  18271. x: number;
  18272. /**
  18273. * Y coordinate of touch.
  18274. */
  18275. y: number;
  18276. /**
  18277. * Id of touch. Unique for each finger.
  18278. */
  18279. pointerId: number;
  18280. /**
  18281. * Event type passed from DOM.
  18282. */
  18283. type: any;
  18284. }
  18285. }
  18286. declare module BABYLON {
  18287. /**
  18288. * Manage the mouse inputs to control the movement of a free camera.
  18289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18290. */
  18291. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18292. /**
  18293. * Define if touch is enabled in the mouse input
  18294. */
  18295. touchEnabled: boolean;
  18296. /**
  18297. * Defines the camera the input is attached to.
  18298. */
  18299. camera: FreeCamera;
  18300. /**
  18301. * Defines the buttons associated with the input to handle camera move.
  18302. */
  18303. buttons: number[];
  18304. /**
  18305. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18306. */
  18307. angularSensibility: number;
  18308. private _pointerInput;
  18309. private _onMouseMove;
  18310. private _observer;
  18311. private previousPosition;
  18312. /**
  18313. * Observable for when a pointer move event occurs containing the move offset
  18314. */
  18315. onPointerMovedObservable: Observable<{
  18316. offsetX: number;
  18317. offsetY: number;
  18318. }>;
  18319. /**
  18320. * @hidden
  18321. * If the camera should be rotated automatically based on pointer movement
  18322. */
  18323. _allowCameraRotation: boolean;
  18324. /**
  18325. * Manage the mouse inputs to control the movement of a free camera.
  18326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18327. * @param touchEnabled Defines if touch is enabled or not
  18328. */
  18329. constructor(
  18330. /**
  18331. * Define if touch is enabled in the mouse input
  18332. */
  18333. touchEnabled?: boolean);
  18334. /**
  18335. * Attach the input controls to a specific dom element to get the input from.
  18336. * @param element Defines the element the controls should be listened from
  18337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18338. */
  18339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18340. /**
  18341. * Called on JS contextmenu event.
  18342. * Override this method to provide functionality.
  18343. */
  18344. protected onContextMenu(evt: PointerEvent): void;
  18345. /**
  18346. * Detach the current controls from the specified dom element.
  18347. * @param element Defines the element to stop listening the inputs from
  18348. */
  18349. detachControl(element: Nullable<HTMLElement>): void;
  18350. /**
  18351. * Gets the class name of the current intput.
  18352. * @returns the class name
  18353. */
  18354. getClassName(): string;
  18355. /**
  18356. * Get the friendly name associated with the input class.
  18357. * @returns the input friendly name
  18358. */
  18359. getSimpleName(): string;
  18360. }
  18361. }
  18362. declare module BABYLON {
  18363. /**
  18364. * Manage the touch inputs to control the movement of a free camera.
  18365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18366. */
  18367. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18368. /**
  18369. * Defines the camera the input is attached to.
  18370. */
  18371. camera: FreeCamera;
  18372. /**
  18373. * Defines the touch sensibility for rotation.
  18374. * The higher the faster.
  18375. */
  18376. touchAngularSensibility: number;
  18377. /**
  18378. * Defines the touch sensibility for move.
  18379. * The higher the faster.
  18380. */
  18381. touchMoveSensibility: number;
  18382. private _offsetX;
  18383. private _offsetY;
  18384. private _pointerPressed;
  18385. private _pointerInput;
  18386. private _observer;
  18387. private _onLostFocus;
  18388. /**
  18389. * Attach the input controls to a specific dom element to get the input from.
  18390. * @param element Defines the element the controls should be listened from
  18391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18392. */
  18393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18394. /**
  18395. * Detach the current controls from the specified dom element.
  18396. * @param element Defines the element to stop listening the inputs from
  18397. */
  18398. detachControl(element: Nullable<HTMLElement>): void;
  18399. /**
  18400. * Update the current camera state depending on the inputs that have been used this frame.
  18401. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18402. */
  18403. checkInputs(): void;
  18404. /**
  18405. * Gets the class name of the current intput.
  18406. * @returns the class name
  18407. */
  18408. getClassName(): string;
  18409. /**
  18410. * Get the friendly name associated with the input class.
  18411. * @returns the input friendly name
  18412. */
  18413. getSimpleName(): string;
  18414. }
  18415. }
  18416. declare module BABYLON {
  18417. /**
  18418. * Default Inputs manager for the FreeCamera.
  18419. * It groups all the default supported inputs for ease of use.
  18420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18421. */
  18422. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18423. /**
  18424. * @hidden
  18425. */
  18426. _mouseInput: Nullable<FreeCameraMouseInput>;
  18427. /**
  18428. * Instantiates a new FreeCameraInputsManager.
  18429. * @param camera Defines the camera the inputs belong to
  18430. */
  18431. constructor(camera: FreeCamera);
  18432. /**
  18433. * Add keyboard input support to the input manager.
  18434. * @returns the current input manager
  18435. */
  18436. addKeyboard(): FreeCameraInputsManager;
  18437. /**
  18438. * Add mouse input support to the input manager.
  18439. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18440. * @returns the current input manager
  18441. */
  18442. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18443. /**
  18444. * Removes the mouse input support from the manager
  18445. * @returns the current input manager
  18446. */
  18447. removeMouse(): FreeCameraInputsManager;
  18448. /**
  18449. * Add touch input support to the input manager.
  18450. * @returns the current input manager
  18451. */
  18452. addTouch(): FreeCameraInputsManager;
  18453. /**
  18454. * Remove all attached input methods from a camera
  18455. */
  18456. clear(): void;
  18457. }
  18458. }
  18459. declare module BABYLON {
  18460. /**
  18461. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18462. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18463. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18464. */
  18465. export class FreeCamera extends TargetCamera {
  18466. /**
  18467. * Define the collision ellipsoid of the camera.
  18468. * This is helpful to simulate a camera body like the player body around the camera
  18469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18470. */
  18471. ellipsoid: Vector3;
  18472. /**
  18473. * Define an offset for the position of the ellipsoid around the camera.
  18474. * This can be helpful to determine the center of the body near the gravity center of the body
  18475. * instead of its head.
  18476. */
  18477. ellipsoidOffset: Vector3;
  18478. /**
  18479. * Enable or disable collisions of the camera with the rest of the scene objects.
  18480. */
  18481. checkCollisions: boolean;
  18482. /**
  18483. * Enable or disable gravity on the camera.
  18484. */
  18485. applyGravity: boolean;
  18486. /**
  18487. * Define the input manager associated to the camera.
  18488. */
  18489. inputs: FreeCameraInputsManager;
  18490. /**
  18491. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18492. * Higher values reduce sensitivity.
  18493. */
  18494. get angularSensibility(): number;
  18495. /**
  18496. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18497. * Higher values reduce sensitivity.
  18498. */
  18499. set angularSensibility(value: number);
  18500. /**
  18501. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18502. */
  18503. get keysUp(): number[];
  18504. set keysUp(value: number[]);
  18505. /**
  18506. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18507. */
  18508. get keysUpward(): number[];
  18509. set keysUpward(value: number[]);
  18510. /**
  18511. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18512. */
  18513. get keysDown(): number[];
  18514. set keysDown(value: number[]);
  18515. /**
  18516. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18517. */
  18518. get keysDownward(): number[];
  18519. set keysDownward(value: number[]);
  18520. /**
  18521. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18522. */
  18523. get keysLeft(): number[];
  18524. set keysLeft(value: number[]);
  18525. /**
  18526. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18527. */
  18528. get keysRight(): number[];
  18529. set keysRight(value: number[]);
  18530. /**
  18531. * Event raised when the camera collide with a mesh in the scene.
  18532. */
  18533. onCollide: (collidedMesh: AbstractMesh) => void;
  18534. private _collider;
  18535. private _needMoveForGravity;
  18536. private _oldPosition;
  18537. private _diffPosition;
  18538. private _newPosition;
  18539. /** @hidden */
  18540. _localDirection: Vector3;
  18541. /** @hidden */
  18542. _transformedDirection: Vector3;
  18543. /**
  18544. * Instantiates a Free Camera.
  18545. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18546. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18548. * @param name Define the name of the camera in the scene
  18549. * @param position Define the start position of the camera in the scene
  18550. * @param scene Define the scene the camera belongs to
  18551. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18552. */
  18553. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18554. /**
  18555. * Attached controls to the current camera.
  18556. * @param element Defines the element the controls should be listened from
  18557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18558. */
  18559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18560. /**
  18561. * Detach the current controls from the camera.
  18562. * The camera will stop reacting to inputs.
  18563. * @param element Defines the element to stop listening the inputs from
  18564. */
  18565. detachControl(element: HTMLElement): void;
  18566. private _collisionMask;
  18567. /**
  18568. * Define a collision mask to limit the list of object the camera can collide with
  18569. */
  18570. get collisionMask(): number;
  18571. set collisionMask(mask: number);
  18572. /** @hidden */
  18573. _collideWithWorld(displacement: Vector3): void;
  18574. private _onCollisionPositionChange;
  18575. /** @hidden */
  18576. _checkInputs(): void;
  18577. /** @hidden */
  18578. _decideIfNeedsToMove(): boolean;
  18579. /** @hidden */
  18580. _updatePosition(): void;
  18581. /**
  18582. * Destroy the camera and release the current resources hold by it.
  18583. */
  18584. dispose(): void;
  18585. /**
  18586. * Gets the current object class name.
  18587. * @return the class name
  18588. */
  18589. getClassName(): string;
  18590. }
  18591. }
  18592. declare module BABYLON {
  18593. /**
  18594. * Represents a gamepad control stick position
  18595. */
  18596. export class StickValues {
  18597. /**
  18598. * The x component of the control stick
  18599. */
  18600. x: number;
  18601. /**
  18602. * The y component of the control stick
  18603. */
  18604. y: number;
  18605. /**
  18606. * Initializes the gamepad x and y control stick values
  18607. * @param x The x component of the gamepad control stick value
  18608. * @param y The y component of the gamepad control stick value
  18609. */
  18610. constructor(
  18611. /**
  18612. * The x component of the control stick
  18613. */
  18614. x: number,
  18615. /**
  18616. * The y component of the control stick
  18617. */
  18618. y: number);
  18619. }
  18620. /**
  18621. * An interface which manages callbacks for gamepad button changes
  18622. */
  18623. export interface GamepadButtonChanges {
  18624. /**
  18625. * Called when a gamepad has been changed
  18626. */
  18627. changed: boolean;
  18628. /**
  18629. * Called when a gamepad press event has been triggered
  18630. */
  18631. pressChanged: boolean;
  18632. /**
  18633. * Called when a touch event has been triggered
  18634. */
  18635. touchChanged: boolean;
  18636. /**
  18637. * Called when a value has changed
  18638. */
  18639. valueChanged: boolean;
  18640. }
  18641. /**
  18642. * Represents a gamepad
  18643. */
  18644. export class Gamepad {
  18645. /**
  18646. * The id of the gamepad
  18647. */
  18648. id: string;
  18649. /**
  18650. * The index of the gamepad
  18651. */
  18652. index: number;
  18653. /**
  18654. * The browser gamepad
  18655. */
  18656. browserGamepad: any;
  18657. /**
  18658. * Specifies what type of gamepad this represents
  18659. */
  18660. type: number;
  18661. private _leftStick;
  18662. private _rightStick;
  18663. /** @hidden */
  18664. _isConnected: boolean;
  18665. private _leftStickAxisX;
  18666. private _leftStickAxisY;
  18667. private _rightStickAxisX;
  18668. private _rightStickAxisY;
  18669. /**
  18670. * Triggered when the left control stick has been changed
  18671. */
  18672. private _onleftstickchanged;
  18673. /**
  18674. * Triggered when the right control stick has been changed
  18675. */
  18676. private _onrightstickchanged;
  18677. /**
  18678. * Represents a gamepad controller
  18679. */
  18680. static GAMEPAD: number;
  18681. /**
  18682. * Represents a generic controller
  18683. */
  18684. static GENERIC: number;
  18685. /**
  18686. * Represents an XBox controller
  18687. */
  18688. static XBOX: number;
  18689. /**
  18690. * Represents a pose-enabled controller
  18691. */
  18692. static POSE_ENABLED: number;
  18693. /**
  18694. * Represents an Dual Shock controller
  18695. */
  18696. static DUALSHOCK: number;
  18697. /**
  18698. * Specifies whether the left control stick should be Y-inverted
  18699. */
  18700. protected _invertLeftStickY: boolean;
  18701. /**
  18702. * Specifies if the gamepad has been connected
  18703. */
  18704. get isConnected(): boolean;
  18705. /**
  18706. * Initializes the gamepad
  18707. * @param id The id of the gamepad
  18708. * @param index The index of the gamepad
  18709. * @param browserGamepad The browser gamepad
  18710. * @param leftStickX The x component of the left joystick
  18711. * @param leftStickY The y component of the left joystick
  18712. * @param rightStickX The x component of the right joystick
  18713. * @param rightStickY The y component of the right joystick
  18714. */
  18715. constructor(
  18716. /**
  18717. * The id of the gamepad
  18718. */
  18719. id: string,
  18720. /**
  18721. * The index of the gamepad
  18722. */
  18723. index: number,
  18724. /**
  18725. * The browser gamepad
  18726. */
  18727. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18728. /**
  18729. * Callback triggered when the left joystick has changed
  18730. * @param callback
  18731. */
  18732. onleftstickchanged(callback: (values: StickValues) => void): void;
  18733. /**
  18734. * Callback triggered when the right joystick has changed
  18735. * @param callback
  18736. */
  18737. onrightstickchanged(callback: (values: StickValues) => void): void;
  18738. /**
  18739. * Gets the left joystick
  18740. */
  18741. get leftStick(): StickValues;
  18742. /**
  18743. * Sets the left joystick values
  18744. */
  18745. set leftStick(newValues: StickValues);
  18746. /**
  18747. * Gets the right joystick
  18748. */
  18749. get rightStick(): StickValues;
  18750. /**
  18751. * Sets the right joystick value
  18752. */
  18753. set rightStick(newValues: StickValues);
  18754. /**
  18755. * Updates the gamepad joystick positions
  18756. */
  18757. update(): void;
  18758. /**
  18759. * Disposes the gamepad
  18760. */
  18761. dispose(): void;
  18762. }
  18763. /**
  18764. * Represents a generic gamepad
  18765. */
  18766. export class GenericPad extends Gamepad {
  18767. private _buttons;
  18768. private _onbuttondown;
  18769. private _onbuttonup;
  18770. /**
  18771. * Observable triggered when a button has been pressed
  18772. */
  18773. onButtonDownObservable: Observable<number>;
  18774. /**
  18775. * Observable triggered when a button has been released
  18776. */
  18777. onButtonUpObservable: Observable<number>;
  18778. /**
  18779. * Callback triggered when a button has been pressed
  18780. * @param callback Called when a button has been pressed
  18781. */
  18782. onbuttondown(callback: (buttonPressed: number) => void): void;
  18783. /**
  18784. * Callback triggered when a button has been released
  18785. * @param callback Called when a button has been released
  18786. */
  18787. onbuttonup(callback: (buttonReleased: number) => void): void;
  18788. /**
  18789. * Initializes the generic gamepad
  18790. * @param id The id of the generic gamepad
  18791. * @param index The index of the generic gamepad
  18792. * @param browserGamepad The browser gamepad
  18793. */
  18794. constructor(id: string, index: number, browserGamepad: any);
  18795. private _setButtonValue;
  18796. /**
  18797. * Updates the generic gamepad
  18798. */
  18799. update(): void;
  18800. /**
  18801. * Disposes the generic gamepad
  18802. */
  18803. dispose(): void;
  18804. }
  18805. }
  18806. declare module BABYLON {
  18807. /**
  18808. * Defines the types of pose enabled controllers that are supported
  18809. */
  18810. export enum PoseEnabledControllerType {
  18811. /**
  18812. * HTC Vive
  18813. */
  18814. VIVE = 0,
  18815. /**
  18816. * Oculus Rift
  18817. */
  18818. OCULUS = 1,
  18819. /**
  18820. * Windows mixed reality
  18821. */
  18822. WINDOWS = 2,
  18823. /**
  18824. * Samsung gear VR
  18825. */
  18826. GEAR_VR = 3,
  18827. /**
  18828. * Google Daydream
  18829. */
  18830. DAYDREAM = 4,
  18831. /**
  18832. * Generic
  18833. */
  18834. GENERIC = 5
  18835. }
  18836. /**
  18837. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18838. */
  18839. export interface MutableGamepadButton {
  18840. /**
  18841. * Value of the button/trigger
  18842. */
  18843. value: number;
  18844. /**
  18845. * If the button/trigger is currently touched
  18846. */
  18847. touched: boolean;
  18848. /**
  18849. * If the button/trigger is currently pressed
  18850. */
  18851. pressed: boolean;
  18852. }
  18853. /**
  18854. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18855. * @hidden
  18856. */
  18857. export interface ExtendedGamepadButton extends GamepadButton {
  18858. /**
  18859. * If the button/trigger is currently pressed
  18860. */
  18861. readonly pressed: boolean;
  18862. /**
  18863. * If the button/trigger is currently touched
  18864. */
  18865. readonly touched: boolean;
  18866. /**
  18867. * Value of the button/trigger
  18868. */
  18869. readonly value: number;
  18870. }
  18871. /** @hidden */
  18872. export interface _GamePadFactory {
  18873. /**
  18874. * Returns whether or not the current gamepad can be created for this type of controller.
  18875. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18876. * @returns true if it can be created, otherwise false
  18877. */
  18878. canCreate(gamepadInfo: any): boolean;
  18879. /**
  18880. * Creates a new instance of the Gamepad.
  18881. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18882. * @returns the new gamepad instance
  18883. */
  18884. create(gamepadInfo: any): Gamepad;
  18885. }
  18886. /**
  18887. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18888. */
  18889. export class PoseEnabledControllerHelper {
  18890. /** @hidden */
  18891. static _ControllerFactories: _GamePadFactory[];
  18892. /** @hidden */
  18893. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18894. /**
  18895. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18896. * @param vrGamepad the gamepad to initialized
  18897. * @returns a vr controller of the type the gamepad identified as
  18898. */
  18899. static InitiateController(vrGamepad: any): Gamepad;
  18900. }
  18901. /**
  18902. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18903. */
  18904. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18905. /**
  18906. * If the controller is used in a webXR session
  18907. */
  18908. isXR: boolean;
  18909. private _deviceRoomPosition;
  18910. private _deviceRoomRotationQuaternion;
  18911. /**
  18912. * The device position in babylon space
  18913. */
  18914. devicePosition: Vector3;
  18915. /**
  18916. * The device rotation in babylon space
  18917. */
  18918. deviceRotationQuaternion: Quaternion;
  18919. /**
  18920. * The scale factor of the device in babylon space
  18921. */
  18922. deviceScaleFactor: number;
  18923. /**
  18924. * (Likely devicePosition should be used instead) The device position in its room space
  18925. */
  18926. position: Vector3;
  18927. /**
  18928. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18929. */
  18930. rotationQuaternion: Quaternion;
  18931. /**
  18932. * The type of controller (Eg. Windows mixed reality)
  18933. */
  18934. controllerType: PoseEnabledControllerType;
  18935. protected _calculatedPosition: Vector3;
  18936. private _calculatedRotation;
  18937. /**
  18938. * The raw pose from the device
  18939. */
  18940. rawPose: DevicePose;
  18941. private _trackPosition;
  18942. private _maxRotationDistFromHeadset;
  18943. private _draggedRoomRotation;
  18944. /**
  18945. * @hidden
  18946. */
  18947. _disableTrackPosition(fixedPosition: Vector3): void;
  18948. /**
  18949. * Internal, the mesh attached to the controller
  18950. * @hidden
  18951. */
  18952. _mesh: Nullable<AbstractMesh>;
  18953. private _poseControlledCamera;
  18954. private _leftHandSystemQuaternion;
  18955. /**
  18956. * Internal, matrix used to convert room space to babylon space
  18957. * @hidden
  18958. */
  18959. _deviceToWorld: Matrix;
  18960. /**
  18961. * Node to be used when casting a ray from the controller
  18962. * @hidden
  18963. */
  18964. _pointingPoseNode: Nullable<TransformNode>;
  18965. /**
  18966. * Name of the child mesh that can be used to cast a ray from the controller
  18967. */
  18968. static readonly POINTING_POSE: string;
  18969. /**
  18970. * Creates a new PoseEnabledController from a gamepad
  18971. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18972. */
  18973. constructor(browserGamepad: any);
  18974. private _workingMatrix;
  18975. /**
  18976. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18977. */
  18978. update(): void;
  18979. /**
  18980. * Updates only the pose device and mesh without doing any button event checking
  18981. */
  18982. protected _updatePoseAndMesh(): void;
  18983. /**
  18984. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18985. * @param poseData raw pose fromthe device
  18986. */
  18987. updateFromDevice(poseData: DevicePose): void;
  18988. /**
  18989. * @hidden
  18990. */
  18991. _meshAttachedObservable: Observable<AbstractMesh>;
  18992. /**
  18993. * Attaches a mesh to the controller
  18994. * @param mesh the mesh to be attached
  18995. */
  18996. attachToMesh(mesh: AbstractMesh): void;
  18997. /**
  18998. * Attaches the controllers mesh to a camera
  18999. * @param camera the camera the mesh should be attached to
  19000. */
  19001. attachToPoseControlledCamera(camera: TargetCamera): void;
  19002. /**
  19003. * Disposes of the controller
  19004. */
  19005. dispose(): void;
  19006. /**
  19007. * The mesh that is attached to the controller
  19008. */
  19009. get mesh(): Nullable<AbstractMesh>;
  19010. /**
  19011. * Gets the ray of the controller in the direction the controller is pointing
  19012. * @param length the length the resulting ray should be
  19013. * @returns a ray in the direction the controller is pointing
  19014. */
  19015. getForwardRay(length?: number): Ray;
  19016. }
  19017. }
  19018. declare module BABYLON {
  19019. /**
  19020. * Defines the WebVRController object that represents controllers tracked in 3D space
  19021. */
  19022. export abstract class WebVRController extends PoseEnabledController {
  19023. /**
  19024. * Internal, the default controller model for the controller
  19025. */
  19026. protected _defaultModel: Nullable<AbstractMesh>;
  19027. /**
  19028. * Fired when the trigger state has changed
  19029. */
  19030. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19031. /**
  19032. * Fired when the main button state has changed
  19033. */
  19034. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19035. /**
  19036. * Fired when the secondary button state has changed
  19037. */
  19038. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19039. /**
  19040. * Fired when the pad state has changed
  19041. */
  19042. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19043. /**
  19044. * Fired when controllers stick values have changed
  19045. */
  19046. onPadValuesChangedObservable: Observable<StickValues>;
  19047. /**
  19048. * Array of button availible on the controller
  19049. */
  19050. protected _buttons: Array<MutableGamepadButton>;
  19051. private _onButtonStateChange;
  19052. /**
  19053. * Fired when a controller button's state has changed
  19054. * @param callback the callback containing the button that was modified
  19055. */
  19056. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19057. /**
  19058. * X and Y axis corresponding to the controllers joystick
  19059. */
  19060. pad: StickValues;
  19061. /**
  19062. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19063. */
  19064. hand: string;
  19065. /**
  19066. * The default controller model for the controller
  19067. */
  19068. get defaultModel(): Nullable<AbstractMesh>;
  19069. /**
  19070. * Creates a new WebVRController from a gamepad
  19071. * @param vrGamepad the gamepad that the WebVRController should be created from
  19072. */
  19073. constructor(vrGamepad: any);
  19074. /**
  19075. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19076. */
  19077. update(): void;
  19078. /**
  19079. * Function to be called when a button is modified
  19080. */
  19081. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19082. /**
  19083. * Loads a mesh and attaches it to the controller
  19084. * @param scene the scene the mesh should be added to
  19085. * @param meshLoaded callback for when the mesh has been loaded
  19086. */
  19087. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19088. private _setButtonValue;
  19089. private _changes;
  19090. private _checkChanges;
  19091. /**
  19092. * Disposes of th webVRCOntroller
  19093. */
  19094. dispose(): void;
  19095. }
  19096. }
  19097. declare module BABYLON {
  19098. /**
  19099. * The HemisphericLight simulates the ambient environment light,
  19100. * so the passed direction is the light reflection direction, not the incoming direction.
  19101. */
  19102. export class HemisphericLight extends Light {
  19103. /**
  19104. * The groundColor is the light in the opposite direction to the one specified during creation.
  19105. * 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.
  19106. */
  19107. groundColor: Color3;
  19108. /**
  19109. * The light reflection direction, not the incoming direction.
  19110. */
  19111. direction: Vector3;
  19112. /**
  19113. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19114. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19115. * The HemisphericLight can't cast shadows.
  19116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19117. * @param name The friendly name of the light
  19118. * @param direction The direction of the light reflection
  19119. * @param scene The scene the light belongs to
  19120. */
  19121. constructor(name: string, direction: Vector3, scene: Scene);
  19122. protected _buildUniformLayout(): void;
  19123. /**
  19124. * Returns the string "HemisphericLight".
  19125. * @return The class name
  19126. */
  19127. getClassName(): string;
  19128. /**
  19129. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19130. * Returns the updated direction.
  19131. * @param target The target the direction should point to
  19132. * @return The computed direction
  19133. */
  19134. setDirectionToTarget(target: Vector3): Vector3;
  19135. /**
  19136. * Returns the shadow generator associated to the light.
  19137. * @returns Always null for hemispheric lights because it does not support shadows.
  19138. */
  19139. getShadowGenerator(): Nullable<IShadowGenerator>;
  19140. /**
  19141. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19142. * @param effect The effect to update
  19143. * @param lightIndex The index of the light in the effect to update
  19144. * @returns The hemispheric light
  19145. */
  19146. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19147. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19148. /**
  19149. * Computes the world matrix of the node
  19150. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19151. * @param useWasUpdatedFlag defines a reserved property
  19152. * @returns the world matrix
  19153. */
  19154. computeWorldMatrix(): Matrix;
  19155. /**
  19156. * Returns the integer 3.
  19157. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19158. */
  19159. getTypeID(): number;
  19160. /**
  19161. * Prepares the list of defines specific to the light type.
  19162. * @param defines the list of defines
  19163. * @param lightIndex defines the index of the light for the effect
  19164. */
  19165. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19166. }
  19167. }
  19168. declare module BABYLON {
  19169. /** @hidden */
  19170. export var vrMultiviewToSingleviewPixelShader: {
  19171. name: string;
  19172. shader: string;
  19173. };
  19174. }
  19175. declare module BABYLON {
  19176. /**
  19177. * Renders to multiple views with a single draw call
  19178. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19179. */
  19180. export class MultiviewRenderTarget extends RenderTargetTexture {
  19181. /**
  19182. * Creates a multiview render target
  19183. * @param scene scene used with the render target
  19184. * @param size the size of the render target (used for each view)
  19185. */
  19186. constructor(scene: Scene, size?: number | {
  19187. width: number;
  19188. height: number;
  19189. } | {
  19190. ratio: number;
  19191. });
  19192. /**
  19193. * @hidden
  19194. * @param faceIndex the face index, if its a cube texture
  19195. */
  19196. _bindFrameBuffer(faceIndex?: number): void;
  19197. /**
  19198. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19199. * @returns the view count
  19200. */
  19201. getViewCount(): number;
  19202. }
  19203. }
  19204. declare module BABYLON {
  19205. /**
  19206. * Represents a camera frustum
  19207. */
  19208. export class Frustum {
  19209. /**
  19210. * Gets the planes representing the frustum
  19211. * @param transform matrix to be applied to the returned planes
  19212. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19213. */
  19214. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19215. /**
  19216. * Gets the near frustum plane transformed by the transform matrix
  19217. * @param transform transformation matrix to be applied to the resulting frustum plane
  19218. * @param frustumPlane the resuling frustum plane
  19219. */
  19220. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19221. /**
  19222. * Gets the far frustum plane transformed by the transform matrix
  19223. * @param transform transformation matrix to be applied to the resulting frustum plane
  19224. * @param frustumPlane the resuling frustum plane
  19225. */
  19226. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19227. /**
  19228. * Gets the left frustum plane transformed by the transform matrix
  19229. * @param transform transformation matrix to be applied to the resulting frustum plane
  19230. * @param frustumPlane the resuling frustum plane
  19231. */
  19232. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19233. /**
  19234. * Gets the right frustum plane transformed by the transform matrix
  19235. * @param transform transformation matrix to be applied to the resulting frustum plane
  19236. * @param frustumPlane the resuling frustum plane
  19237. */
  19238. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19239. /**
  19240. * Gets the top frustum plane transformed by the transform matrix
  19241. * @param transform transformation matrix to be applied to the resulting frustum plane
  19242. * @param frustumPlane the resuling frustum plane
  19243. */
  19244. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19245. /**
  19246. * Gets the bottom frustum plane transformed by the transform matrix
  19247. * @param transform transformation matrix to be applied to the resulting frustum plane
  19248. * @param frustumPlane the resuling frustum plane
  19249. */
  19250. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19251. /**
  19252. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19253. * @param transform transformation matrix to be applied to the resulting frustum planes
  19254. * @param frustumPlanes the resuling frustum planes
  19255. */
  19256. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19257. }
  19258. }
  19259. declare module BABYLON {
  19260. interface Engine {
  19261. /**
  19262. * Creates a new multiview render target
  19263. * @param width defines the width of the texture
  19264. * @param height defines the height of the texture
  19265. * @returns the created multiview texture
  19266. */
  19267. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19268. /**
  19269. * Binds a multiview framebuffer to be drawn to
  19270. * @param multiviewTexture texture to bind
  19271. */
  19272. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19273. }
  19274. interface Camera {
  19275. /**
  19276. * @hidden
  19277. * 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)
  19278. */
  19279. _useMultiviewToSingleView: boolean;
  19280. /**
  19281. * @hidden
  19282. * 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)
  19283. */
  19284. _multiviewTexture: Nullable<RenderTargetTexture>;
  19285. /**
  19286. * @hidden
  19287. * ensures the multiview texture of the camera exists and has the specified width/height
  19288. * @param width height to set on the multiview texture
  19289. * @param height width to set on the multiview texture
  19290. */
  19291. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19292. }
  19293. interface Scene {
  19294. /** @hidden */
  19295. _transformMatrixR: Matrix;
  19296. /** @hidden */
  19297. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19298. /** @hidden */
  19299. _createMultiviewUbo(): void;
  19300. /** @hidden */
  19301. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19302. /** @hidden */
  19303. _renderMultiviewToSingleView(camera: Camera): void;
  19304. }
  19305. }
  19306. declare module BABYLON {
  19307. /**
  19308. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19309. * This will not be used for webXR as it supports displaying texture arrays directly
  19310. */
  19311. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19312. /**
  19313. * Initializes a VRMultiviewToSingleview
  19314. * @param name name of the post process
  19315. * @param camera camera to be applied to
  19316. * @param scaleFactor scaling factor to the size of the output texture
  19317. */
  19318. constructor(name: string, camera: Camera, scaleFactor: number);
  19319. }
  19320. }
  19321. declare module BABYLON {
  19322. /**
  19323. * Interface used to define additional presentation attributes
  19324. */
  19325. export interface IVRPresentationAttributes {
  19326. /**
  19327. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19328. */
  19329. highRefreshRate: boolean;
  19330. /**
  19331. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19332. */
  19333. foveationLevel: number;
  19334. }
  19335. interface Engine {
  19336. /** @hidden */
  19337. _vrDisplay: any;
  19338. /** @hidden */
  19339. _vrSupported: boolean;
  19340. /** @hidden */
  19341. _oldSize: Size;
  19342. /** @hidden */
  19343. _oldHardwareScaleFactor: number;
  19344. /** @hidden */
  19345. _vrExclusivePointerMode: boolean;
  19346. /** @hidden */
  19347. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19348. /** @hidden */
  19349. _onVRDisplayPointerRestricted: () => void;
  19350. /** @hidden */
  19351. _onVRDisplayPointerUnrestricted: () => void;
  19352. /** @hidden */
  19353. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19354. /** @hidden */
  19355. _onVrDisplayDisconnect: Nullable<() => void>;
  19356. /** @hidden */
  19357. _onVrDisplayPresentChange: Nullable<() => void>;
  19358. /**
  19359. * Observable signaled when VR display mode changes
  19360. */
  19361. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19362. /**
  19363. * Observable signaled when VR request present is complete
  19364. */
  19365. onVRRequestPresentComplete: Observable<boolean>;
  19366. /**
  19367. * Observable signaled when VR request present starts
  19368. */
  19369. onVRRequestPresentStart: Observable<Engine>;
  19370. /**
  19371. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19372. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19373. */
  19374. isInVRExclusivePointerMode: boolean;
  19375. /**
  19376. * Gets a boolean indicating if a webVR device was detected
  19377. * @returns true if a webVR device was detected
  19378. */
  19379. isVRDevicePresent(): boolean;
  19380. /**
  19381. * Gets the current webVR device
  19382. * @returns the current webVR device (or null)
  19383. */
  19384. getVRDevice(): any;
  19385. /**
  19386. * Initializes a webVR display and starts listening to display change events
  19387. * The onVRDisplayChangedObservable will be notified upon these changes
  19388. * @returns A promise containing a VRDisplay and if vr is supported
  19389. */
  19390. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19391. /** @hidden */
  19392. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19393. /**
  19394. * Gets or sets the presentation attributes used to configure VR rendering
  19395. */
  19396. vrPresentationAttributes?: IVRPresentationAttributes;
  19397. /**
  19398. * Call this function to switch to webVR mode
  19399. * Will do nothing if webVR is not supported or if there is no webVR device
  19400. * @param options the webvr options provided to the camera. mainly used for multiview
  19401. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19402. */
  19403. enableVR(options: WebVROptions): void;
  19404. /** @hidden */
  19405. _onVRFullScreenTriggered(): void;
  19406. }
  19407. }
  19408. declare module BABYLON {
  19409. /**
  19410. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19411. * IMPORTANT!! The data is right-hand data.
  19412. * @export
  19413. * @interface DevicePose
  19414. */
  19415. export interface DevicePose {
  19416. /**
  19417. * The position of the device, values in array are [x,y,z].
  19418. */
  19419. readonly position: Nullable<Float32Array>;
  19420. /**
  19421. * The linearVelocity of the device, values in array are [x,y,z].
  19422. */
  19423. readonly linearVelocity: Nullable<Float32Array>;
  19424. /**
  19425. * The linearAcceleration of the device, values in array are [x,y,z].
  19426. */
  19427. readonly linearAcceleration: Nullable<Float32Array>;
  19428. /**
  19429. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19430. */
  19431. readonly orientation: Nullable<Float32Array>;
  19432. /**
  19433. * The angularVelocity of the device, values in array are [x,y,z].
  19434. */
  19435. readonly angularVelocity: Nullable<Float32Array>;
  19436. /**
  19437. * The angularAcceleration of the device, values in array are [x,y,z].
  19438. */
  19439. readonly angularAcceleration: Nullable<Float32Array>;
  19440. }
  19441. /**
  19442. * Interface representing a pose controlled object in Babylon.
  19443. * A pose controlled object has both regular pose values as well as pose values
  19444. * from an external device such as a VR head mounted display
  19445. */
  19446. export interface PoseControlled {
  19447. /**
  19448. * The position of the object in babylon space.
  19449. */
  19450. position: Vector3;
  19451. /**
  19452. * The rotation quaternion of the object in babylon space.
  19453. */
  19454. rotationQuaternion: Quaternion;
  19455. /**
  19456. * The position of the device in babylon space.
  19457. */
  19458. devicePosition?: Vector3;
  19459. /**
  19460. * The rotation quaternion of the device in babylon space.
  19461. */
  19462. deviceRotationQuaternion: Quaternion;
  19463. /**
  19464. * The raw pose coming from the device.
  19465. */
  19466. rawPose: Nullable<DevicePose>;
  19467. /**
  19468. * The scale of the device to be used when translating from device space to babylon space.
  19469. */
  19470. deviceScaleFactor: number;
  19471. /**
  19472. * Updates the poseControlled values based on the input device pose.
  19473. * @param poseData the pose data to update the object with
  19474. */
  19475. updateFromDevice(poseData: DevicePose): void;
  19476. }
  19477. /**
  19478. * Set of options to customize the webVRCamera
  19479. */
  19480. export interface WebVROptions {
  19481. /**
  19482. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19483. */
  19484. trackPosition?: boolean;
  19485. /**
  19486. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19487. */
  19488. positionScale?: number;
  19489. /**
  19490. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19491. */
  19492. displayName?: string;
  19493. /**
  19494. * Should the native controller meshes be initialized. (default: true)
  19495. */
  19496. controllerMeshes?: boolean;
  19497. /**
  19498. * Creating a default HemiLight only on controllers. (default: true)
  19499. */
  19500. defaultLightingOnControllers?: boolean;
  19501. /**
  19502. * If you don't want to use the default VR button of the helper. (default: false)
  19503. */
  19504. useCustomVRButton?: boolean;
  19505. /**
  19506. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19507. */
  19508. customVRButton?: HTMLButtonElement;
  19509. /**
  19510. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19511. */
  19512. rayLength?: number;
  19513. /**
  19514. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19515. */
  19516. defaultHeight?: number;
  19517. /**
  19518. * If multiview should be used if availible (default: false)
  19519. */
  19520. useMultiview?: boolean;
  19521. }
  19522. /**
  19523. * This represents a WebVR camera.
  19524. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19525. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19526. */
  19527. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19528. private webVROptions;
  19529. /**
  19530. * @hidden
  19531. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19532. */
  19533. _vrDevice: any;
  19534. /**
  19535. * The rawPose of the vrDevice.
  19536. */
  19537. rawPose: Nullable<DevicePose>;
  19538. private _onVREnabled;
  19539. private _specsVersion;
  19540. private _attached;
  19541. private _frameData;
  19542. protected _descendants: Array<Node>;
  19543. private _deviceRoomPosition;
  19544. /** @hidden */
  19545. _deviceRoomRotationQuaternion: Quaternion;
  19546. private _standingMatrix;
  19547. /**
  19548. * Represents device position in babylon space.
  19549. */
  19550. devicePosition: Vector3;
  19551. /**
  19552. * Represents device rotation in babylon space.
  19553. */
  19554. deviceRotationQuaternion: Quaternion;
  19555. /**
  19556. * The scale of the device to be used when translating from device space to babylon space.
  19557. */
  19558. deviceScaleFactor: number;
  19559. private _deviceToWorld;
  19560. private _worldToDevice;
  19561. /**
  19562. * References to the webVR controllers for the vrDevice.
  19563. */
  19564. controllers: Array<WebVRController>;
  19565. /**
  19566. * Emits an event when a controller is attached.
  19567. */
  19568. onControllersAttachedObservable: Observable<WebVRController[]>;
  19569. /**
  19570. * Emits an event when a controller's mesh has been loaded;
  19571. */
  19572. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19573. /**
  19574. * Emits an event when the HMD's pose has been updated.
  19575. */
  19576. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19577. private _poseSet;
  19578. /**
  19579. * If the rig cameras be used as parent instead of this camera.
  19580. */
  19581. rigParenting: boolean;
  19582. private _lightOnControllers;
  19583. private _defaultHeight?;
  19584. /**
  19585. * Instantiates a WebVRFreeCamera.
  19586. * @param name The name of the WebVRFreeCamera
  19587. * @param position The starting anchor position for the camera
  19588. * @param scene The scene the camera belongs to
  19589. * @param webVROptions a set of customizable options for the webVRCamera
  19590. */
  19591. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19592. /**
  19593. * Gets the device distance from the ground in meters.
  19594. * @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.
  19595. */
  19596. deviceDistanceToRoomGround(): number;
  19597. /**
  19598. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19599. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19600. */
  19601. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19602. /**
  19603. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19604. * @returns A promise with a boolean set to if the standing matrix is supported.
  19605. */
  19606. useStandingMatrixAsync(): Promise<boolean>;
  19607. /**
  19608. * Disposes the camera
  19609. */
  19610. dispose(): void;
  19611. /**
  19612. * Gets a vrController by name.
  19613. * @param name The name of the controller to retreive
  19614. * @returns the controller matching the name specified or null if not found
  19615. */
  19616. getControllerByName(name: string): Nullable<WebVRController>;
  19617. private _leftController;
  19618. /**
  19619. * The controller corresponding to the users left hand.
  19620. */
  19621. get leftController(): Nullable<WebVRController>;
  19622. private _rightController;
  19623. /**
  19624. * The controller corresponding to the users right hand.
  19625. */
  19626. get rightController(): Nullable<WebVRController>;
  19627. /**
  19628. * Casts a ray forward from the vrCamera's gaze.
  19629. * @param length Length of the ray (default: 100)
  19630. * @returns the ray corresponding to the gaze
  19631. */
  19632. getForwardRay(length?: number): Ray;
  19633. /**
  19634. * @hidden
  19635. * Updates the camera based on device's frame data
  19636. */
  19637. _checkInputs(): void;
  19638. /**
  19639. * Updates the poseControlled values based on the input device pose.
  19640. * @param poseData Pose coming from the device
  19641. */
  19642. updateFromDevice(poseData: DevicePose): void;
  19643. private _htmlElementAttached;
  19644. private _detachIfAttached;
  19645. /**
  19646. * WebVR's attach control will start broadcasting frames to the device.
  19647. * Note that in certain browsers (chrome for example) this function must be called
  19648. * within a user-interaction callback. Example:
  19649. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19650. *
  19651. * @param element html element to attach the vrDevice to
  19652. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19653. */
  19654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19655. /**
  19656. * Detaches the camera from the html element and disables VR
  19657. *
  19658. * @param element html element to detach from
  19659. */
  19660. detachControl(element: HTMLElement): void;
  19661. /**
  19662. * @returns the name of this class
  19663. */
  19664. getClassName(): string;
  19665. /**
  19666. * Calls resetPose on the vrDisplay
  19667. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19668. */
  19669. resetToCurrentRotation(): void;
  19670. /**
  19671. * @hidden
  19672. * Updates the rig cameras (left and right eye)
  19673. */
  19674. _updateRigCameras(): void;
  19675. private _workingVector;
  19676. private _oneVector;
  19677. private _workingMatrix;
  19678. private updateCacheCalled;
  19679. private _correctPositionIfNotTrackPosition;
  19680. /**
  19681. * @hidden
  19682. * Updates the cached values of the camera
  19683. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19684. */
  19685. _updateCache(ignoreParentClass?: boolean): void;
  19686. /**
  19687. * @hidden
  19688. * Get current device position in babylon world
  19689. */
  19690. _computeDevicePosition(): void;
  19691. /**
  19692. * Updates the current device position and rotation in the babylon world
  19693. */
  19694. update(): void;
  19695. /**
  19696. * @hidden
  19697. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19698. * @returns an identity matrix
  19699. */
  19700. _getViewMatrix(): Matrix;
  19701. private _tmpMatrix;
  19702. /**
  19703. * This function is called by the two RIG cameras.
  19704. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19705. * @hidden
  19706. */
  19707. _getWebVRViewMatrix(): Matrix;
  19708. /** @hidden */
  19709. _getWebVRProjectionMatrix(): Matrix;
  19710. private _onGamepadConnectedObserver;
  19711. private _onGamepadDisconnectedObserver;
  19712. private _updateCacheWhenTrackingDisabledObserver;
  19713. /**
  19714. * Initializes the controllers and their meshes
  19715. */
  19716. initControllers(): void;
  19717. }
  19718. }
  19719. declare module BABYLON {
  19720. /**
  19721. * Size options for a post process
  19722. */
  19723. export type PostProcessOptions = {
  19724. width: number;
  19725. height: number;
  19726. };
  19727. /**
  19728. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19729. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19730. */
  19731. export class PostProcess {
  19732. /** Name of the PostProcess. */
  19733. name: string;
  19734. /**
  19735. * Gets or sets the unique id of the post process
  19736. */
  19737. uniqueId: number;
  19738. /**
  19739. * Width of the texture to apply the post process on
  19740. */
  19741. width: number;
  19742. /**
  19743. * Height of the texture to apply the post process on
  19744. */
  19745. height: number;
  19746. /**
  19747. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19748. * @hidden
  19749. */
  19750. _outputTexture: Nullable<InternalTexture>;
  19751. /**
  19752. * Sampling mode used by the shader
  19753. * See https://doc.babylonjs.com/classes/3.1/texture
  19754. */
  19755. renderTargetSamplingMode: number;
  19756. /**
  19757. * Clear color to use when screen clearing
  19758. */
  19759. clearColor: Color4;
  19760. /**
  19761. * If the buffer needs to be cleared before applying the post process. (default: true)
  19762. * Should be set to false if shader will overwrite all previous pixels.
  19763. */
  19764. autoClear: boolean;
  19765. /**
  19766. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19767. */
  19768. alphaMode: number;
  19769. /**
  19770. * Sets the setAlphaBlendConstants of the babylon engine
  19771. */
  19772. alphaConstants: Color4;
  19773. /**
  19774. * Animations to be used for the post processing
  19775. */
  19776. animations: Animation[];
  19777. /**
  19778. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19779. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19780. */
  19781. enablePixelPerfectMode: boolean;
  19782. /**
  19783. * Force the postprocess to be applied without taking in account viewport
  19784. */
  19785. forceFullscreenViewport: boolean;
  19786. /**
  19787. * List of inspectable custom properties (used by the Inspector)
  19788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19789. */
  19790. inspectableCustomProperties: IInspectable[];
  19791. /**
  19792. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19793. *
  19794. * | Value | Type | Description |
  19795. * | ----- | ----------------------------------- | ----------- |
  19796. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19797. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19798. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19799. *
  19800. */
  19801. scaleMode: number;
  19802. /**
  19803. * Force textures to be a power of two (default: false)
  19804. */
  19805. alwaysForcePOT: boolean;
  19806. private _samples;
  19807. /**
  19808. * Number of sample textures (default: 1)
  19809. */
  19810. get samples(): number;
  19811. set samples(n: number);
  19812. /**
  19813. * Modify the scale of the post process to be the same as the viewport (default: false)
  19814. */
  19815. adaptScaleToCurrentViewport: boolean;
  19816. private _camera;
  19817. private _scene;
  19818. private _engine;
  19819. private _options;
  19820. private _reusable;
  19821. private _textureType;
  19822. private _textureFormat;
  19823. /**
  19824. * Smart array of input and output textures for the post process.
  19825. * @hidden
  19826. */
  19827. _textures: SmartArray<InternalTexture>;
  19828. /**
  19829. * The index in _textures that corresponds to the output texture.
  19830. * @hidden
  19831. */
  19832. _currentRenderTextureInd: number;
  19833. private _effect;
  19834. private _samplers;
  19835. private _fragmentUrl;
  19836. private _vertexUrl;
  19837. private _parameters;
  19838. private _scaleRatio;
  19839. protected _indexParameters: any;
  19840. private _shareOutputWithPostProcess;
  19841. private _texelSize;
  19842. private _forcedOutputTexture;
  19843. /**
  19844. * Returns the fragment url or shader name used in the post process.
  19845. * @returns the fragment url or name in the shader store.
  19846. */
  19847. getEffectName(): string;
  19848. /**
  19849. * An event triggered when the postprocess is activated.
  19850. */
  19851. onActivateObservable: Observable<Camera>;
  19852. private _onActivateObserver;
  19853. /**
  19854. * A function that is added to the onActivateObservable
  19855. */
  19856. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19857. /**
  19858. * An event triggered when the postprocess changes its size.
  19859. */
  19860. onSizeChangedObservable: Observable<PostProcess>;
  19861. private _onSizeChangedObserver;
  19862. /**
  19863. * A function that is added to the onSizeChangedObservable
  19864. */
  19865. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19866. /**
  19867. * An event triggered when the postprocess applies its effect.
  19868. */
  19869. onApplyObservable: Observable<Effect>;
  19870. private _onApplyObserver;
  19871. /**
  19872. * A function that is added to the onApplyObservable
  19873. */
  19874. set onApply(callback: (effect: Effect) => void);
  19875. /**
  19876. * An event triggered before rendering the postprocess
  19877. */
  19878. onBeforeRenderObservable: Observable<Effect>;
  19879. private _onBeforeRenderObserver;
  19880. /**
  19881. * A function that is added to the onBeforeRenderObservable
  19882. */
  19883. set onBeforeRender(callback: (effect: Effect) => void);
  19884. /**
  19885. * An event triggered after rendering the postprocess
  19886. */
  19887. onAfterRenderObservable: Observable<Effect>;
  19888. private _onAfterRenderObserver;
  19889. /**
  19890. * A function that is added to the onAfterRenderObservable
  19891. */
  19892. set onAfterRender(callback: (efect: Effect) => void);
  19893. /**
  19894. * 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
  19895. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19896. */
  19897. get inputTexture(): InternalTexture;
  19898. set inputTexture(value: InternalTexture);
  19899. /**
  19900. * Gets the camera which post process is applied to.
  19901. * @returns The camera the post process is applied to.
  19902. */
  19903. getCamera(): Camera;
  19904. /**
  19905. * Gets the texel size of the postprocess.
  19906. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19907. */
  19908. get texelSize(): Vector2;
  19909. /**
  19910. * Creates a new instance PostProcess
  19911. * @param name The name of the PostProcess.
  19912. * @param fragmentUrl The url of the fragment shader to be used.
  19913. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19914. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19915. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19916. * @param camera The camera to apply the render pass to.
  19917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19918. * @param engine The engine which the post process will be applied. (default: current engine)
  19919. * @param reusable If the post process can be reused on the same frame. (default: false)
  19920. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19921. * @param textureType Type of textures used when performing the post process. (default: 0)
  19922. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19923. * @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
  19924. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19925. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19926. */
  19927. constructor(
  19928. /** Name of the PostProcess. */
  19929. 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);
  19930. /**
  19931. * Gets a string idenfifying the name of the class
  19932. * @returns "PostProcess" string
  19933. */
  19934. getClassName(): string;
  19935. /**
  19936. * Gets the engine which this post process belongs to.
  19937. * @returns The engine the post process was enabled with.
  19938. */
  19939. getEngine(): Engine;
  19940. /**
  19941. * The effect that is created when initializing the post process.
  19942. * @returns The created effect corresponding the the postprocess.
  19943. */
  19944. getEffect(): Effect;
  19945. /**
  19946. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19947. * @param postProcess The post process to share the output with.
  19948. * @returns This post process.
  19949. */
  19950. shareOutputWith(postProcess: PostProcess): PostProcess;
  19951. /**
  19952. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19953. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19954. */
  19955. useOwnOutput(): void;
  19956. /**
  19957. * Updates the effect with the current post process compile time values and recompiles the shader.
  19958. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19959. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19960. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19961. * @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
  19962. * @param onCompiled Called when the shader has been compiled.
  19963. * @param onError Called if there is an error when compiling a shader.
  19964. */
  19965. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19966. /**
  19967. * The post process is reusable if it can be used multiple times within one frame.
  19968. * @returns If the post process is reusable
  19969. */
  19970. isReusable(): boolean;
  19971. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19972. markTextureDirty(): void;
  19973. /**
  19974. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19975. * 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.
  19976. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19977. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19978. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19979. * @returns The target texture that was bound to be written to.
  19980. */
  19981. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19982. /**
  19983. * If the post process is supported.
  19984. */
  19985. get isSupported(): boolean;
  19986. /**
  19987. * The aspect ratio of the output texture.
  19988. */
  19989. get aspectRatio(): number;
  19990. /**
  19991. * Get a value indicating if the post-process is ready to be used
  19992. * @returns true if the post-process is ready (shader is compiled)
  19993. */
  19994. isReady(): boolean;
  19995. /**
  19996. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19997. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19998. */
  19999. apply(): Nullable<Effect>;
  20000. private _disposeTextures;
  20001. /**
  20002. * Disposes the post process.
  20003. * @param camera The camera to dispose the post process on.
  20004. */
  20005. dispose(camera?: Camera): void;
  20006. }
  20007. }
  20008. declare module BABYLON {
  20009. /** @hidden */
  20010. export var kernelBlurVaryingDeclaration: {
  20011. name: string;
  20012. shader: string;
  20013. };
  20014. }
  20015. declare module BABYLON {
  20016. /** @hidden */
  20017. export var kernelBlurFragment: {
  20018. name: string;
  20019. shader: string;
  20020. };
  20021. }
  20022. declare module BABYLON {
  20023. /** @hidden */
  20024. export var kernelBlurFragment2: {
  20025. name: string;
  20026. shader: string;
  20027. };
  20028. }
  20029. declare module BABYLON {
  20030. /** @hidden */
  20031. export var kernelBlurPixelShader: {
  20032. name: string;
  20033. shader: string;
  20034. };
  20035. }
  20036. declare module BABYLON {
  20037. /** @hidden */
  20038. export var kernelBlurVertex: {
  20039. name: string;
  20040. shader: string;
  20041. };
  20042. }
  20043. declare module BABYLON {
  20044. /** @hidden */
  20045. export var kernelBlurVertexShader: {
  20046. name: string;
  20047. shader: string;
  20048. };
  20049. }
  20050. declare module BABYLON {
  20051. /**
  20052. * The Blur Post Process which blurs an image based on a kernel and direction.
  20053. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20054. */
  20055. export class BlurPostProcess extends PostProcess {
  20056. /** The direction in which to blur the image. */
  20057. direction: Vector2;
  20058. private blockCompilation;
  20059. protected _kernel: number;
  20060. protected _idealKernel: number;
  20061. protected _packedFloat: boolean;
  20062. private _staticDefines;
  20063. /**
  20064. * Sets the length in pixels of the blur sample region
  20065. */
  20066. set kernel(v: number);
  20067. /**
  20068. * Gets the length in pixels of the blur sample region
  20069. */
  20070. get kernel(): number;
  20071. /**
  20072. * Sets wether or not the blur needs to unpack/repack floats
  20073. */
  20074. set packedFloat(v: boolean);
  20075. /**
  20076. * Gets wether or not the blur is unpacking/repacking floats
  20077. */
  20078. get packedFloat(): boolean;
  20079. /**
  20080. * Creates a new instance BlurPostProcess
  20081. * @param name The name of the effect.
  20082. * @param direction The direction in which to blur the image.
  20083. * @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.
  20084. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20085. * @param camera The camera to apply the render pass to.
  20086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20087. * @param engine The engine which the post process will be applied. (default: current engine)
  20088. * @param reusable If the post process can be reused on the same frame. (default: false)
  20089. * @param textureType Type of textures used when performing the post process. (default: 0)
  20090. * @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)
  20091. */
  20092. constructor(name: string,
  20093. /** The direction in which to blur the image. */
  20094. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20095. /**
  20096. * Updates the effect with the current post process compile time values and recompiles the shader.
  20097. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20098. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20099. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20100. * @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
  20101. * @param onCompiled Called when the shader has been compiled.
  20102. * @param onError Called if there is an error when compiling a shader.
  20103. */
  20104. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20105. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20106. /**
  20107. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20108. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20109. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20110. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20111. * The gaps between physical kernels are compensated for in the weighting of the samples
  20112. * @param idealKernel Ideal blur kernel.
  20113. * @return Nearest best kernel.
  20114. */
  20115. protected _nearestBestKernel(idealKernel: number): number;
  20116. /**
  20117. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20118. * @param x The point on the Gaussian distribution to sample.
  20119. * @return the value of the Gaussian function at x.
  20120. */
  20121. protected _gaussianWeight(x: number): number;
  20122. /**
  20123. * Generates a string that can be used as a floating point number in GLSL.
  20124. * @param x Value to print.
  20125. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20126. * @return GLSL float string.
  20127. */
  20128. protected _glslFloat(x: number, decimalFigures?: number): string;
  20129. }
  20130. }
  20131. declare module BABYLON {
  20132. /**
  20133. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20134. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20135. * You can then easily use it as a reflectionTexture on a flat surface.
  20136. * In case the surface is not a plane, please consider relying on reflection probes.
  20137. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20138. */
  20139. export class MirrorTexture extends RenderTargetTexture {
  20140. private scene;
  20141. /**
  20142. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20143. * 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.
  20144. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20145. */
  20146. mirrorPlane: Plane;
  20147. /**
  20148. * Define the blur ratio used to blur the reflection if needed.
  20149. */
  20150. set blurRatio(value: number);
  20151. get blurRatio(): number;
  20152. /**
  20153. * Define the adaptive blur kernel used to blur the reflection if needed.
  20154. * This will autocompute the closest best match for the `blurKernel`
  20155. */
  20156. set adaptiveBlurKernel(value: number);
  20157. /**
  20158. * Define the blur kernel used to blur the reflection if needed.
  20159. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20160. */
  20161. set blurKernel(value: number);
  20162. /**
  20163. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20164. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20165. */
  20166. set blurKernelX(value: number);
  20167. get blurKernelX(): number;
  20168. /**
  20169. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20171. */
  20172. set blurKernelY(value: number);
  20173. get blurKernelY(): number;
  20174. private _autoComputeBlurKernel;
  20175. protected _onRatioRescale(): void;
  20176. private _updateGammaSpace;
  20177. private _imageProcessingConfigChangeObserver;
  20178. private _transformMatrix;
  20179. private _mirrorMatrix;
  20180. private _savedViewMatrix;
  20181. private _blurX;
  20182. private _blurY;
  20183. private _adaptiveBlurKernel;
  20184. private _blurKernelX;
  20185. private _blurKernelY;
  20186. private _blurRatio;
  20187. /**
  20188. * Instantiates a Mirror Texture.
  20189. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20190. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20191. * You can then easily use it as a reflectionTexture on a flat surface.
  20192. * In case the surface is not a plane, please consider relying on reflection probes.
  20193. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20194. * @param name
  20195. * @param size
  20196. * @param scene
  20197. * @param generateMipMaps
  20198. * @param type
  20199. * @param samplingMode
  20200. * @param generateDepthBuffer
  20201. */
  20202. constructor(name: string, size: number | {
  20203. width: number;
  20204. height: number;
  20205. } | {
  20206. ratio: number;
  20207. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20208. private _preparePostProcesses;
  20209. /**
  20210. * Clone the mirror texture.
  20211. * @returns the cloned texture
  20212. */
  20213. clone(): MirrorTexture;
  20214. /**
  20215. * Serialize the texture to a JSON representation you could use in Parse later on
  20216. * @returns the serialized JSON representation
  20217. */
  20218. serialize(): any;
  20219. /**
  20220. * Dispose the texture and release its associated resources.
  20221. */
  20222. dispose(): void;
  20223. }
  20224. }
  20225. declare module BABYLON {
  20226. /**
  20227. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20228. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20229. */
  20230. export class Texture extends BaseTexture {
  20231. /**
  20232. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20233. */
  20234. static SerializeBuffers: boolean;
  20235. /** @hidden */
  20236. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20237. /** @hidden */
  20238. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20239. /** @hidden */
  20240. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20241. /** nearest is mag = nearest and min = nearest and mip = linear */
  20242. static readonly NEAREST_SAMPLINGMODE: number;
  20243. /** nearest is mag = nearest and min = nearest and mip = linear */
  20244. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20245. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20246. static readonly BILINEAR_SAMPLINGMODE: number;
  20247. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20248. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20249. /** Trilinear is mag = linear and min = linear and mip = linear */
  20250. static readonly TRILINEAR_SAMPLINGMODE: number;
  20251. /** Trilinear is mag = linear and min = linear and mip = linear */
  20252. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20253. /** mag = nearest and min = nearest and mip = nearest */
  20254. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20255. /** mag = nearest and min = linear and mip = nearest */
  20256. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20257. /** mag = nearest and min = linear and mip = linear */
  20258. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20259. /** mag = nearest and min = linear and mip = none */
  20260. static readonly NEAREST_LINEAR: number;
  20261. /** mag = nearest and min = nearest and mip = none */
  20262. static readonly NEAREST_NEAREST: number;
  20263. /** mag = linear and min = nearest and mip = nearest */
  20264. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20265. /** mag = linear and min = nearest and mip = linear */
  20266. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20267. /** mag = linear and min = linear and mip = none */
  20268. static readonly LINEAR_LINEAR: number;
  20269. /** mag = linear and min = nearest and mip = none */
  20270. static readonly LINEAR_NEAREST: number;
  20271. /** Explicit coordinates mode */
  20272. static readonly EXPLICIT_MODE: number;
  20273. /** Spherical coordinates mode */
  20274. static readonly SPHERICAL_MODE: number;
  20275. /** Planar coordinates mode */
  20276. static readonly PLANAR_MODE: number;
  20277. /** Cubic coordinates mode */
  20278. static readonly CUBIC_MODE: number;
  20279. /** Projection coordinates mode */
  20280. static readonly PROJECTION_MODE: number;
  20281. /** Inverse Cubic coordinates mode */
  20282. static readonly SKYBOX_MODE: number;
  20283. /** Inverse Cubic coordinates mode */
  20284. static readonly INVCUBIC_MODE: number;
  20285. /** Equirectangular coordinates mode */
  20286. static readonly EQUIRECTANGULAR_MODE: number;
  20287. /** Equirectangular Fixed coordinates mode */
  20288. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20289. /** Equirectangular Fixed Mirrored coordinates mode */
  20290. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20291. /** Texture is not repeating outside of 0..1 UVs */
  20292. static readonly CLAMP_ADDRESSMODE: number;
  20293. /** Texture is repeating outside of 0..1 UVs */
  20294. static readonly WRAP_ADDRESSMODE: number;
  20295. /** Texture is repeating and mirrored */
  20296. static readonly MIRROR_ADDRESSMODE: number;
  20297. /**
  20298. * 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
  20299. */
  20300. static UseSerializedUrlIfAny: boolean;
  20301. /**
  20302. * Define the url of the texture.
  20303. */
  20304. url: Nullable<string>;
  20305. /**
  20306. * Define an offset on the texture to offset the u coordinates of the UVs
  20307. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20308. */
  20309. uOffset: number;
  20310. /**
  20311. * Define an offset on the texture to offset the v coordinates of the UVs
  20312. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20313. */
  20314. vOffset: number;
  20315. /**
  20316. * Define an offset on the texture to scale the u coordinates of the UVs
  20317. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20318. */
  20319. uScale: number;
  20320. /**
  20321. * Define an offset on the texture to scale the v coordinates of the UVs
  20322. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20323. */
  20324. vScale: number;
  20325. /**
  20326. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20327. * @see http://doc.babylonjs.com/how_to/more_materials
  20328. */
  20329. uAng: number;
  20330. /**
  20331. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20332. * @see http://doc.babylonjs.com/how_to/more_materials
  20333. */
  20334. vAng: number;
  20335. /**
  20336. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20337. * @see http://doc.babylonjs.com/how_to/more_materials
  20338. */
  20339. wAng: number;
  20340. /**
  20341. * Defines the center of rotation (U)
  20342. */
  20343. uRotationCenter: number;
  20344. /**
  20345. * Defines the center of rotation (V)
  20346. */
  20347. vRotationCenter: number;
  20348. /**
  20349. * Defines the center of rotation (W)
  20350. */
  20351. wRotationCenter: number;
  20352. /**
  20353. * Are mip maps generated for this texture or not.
  20354. */
  20355. get noMipmap(): boolean;
  20356. /**
  20357. * List of inspectable custom properties (used by the Inspector)
  20358. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20359. */
  20360. inspectableCustomProperties: Nullable<IInspectable[]>;
  20361. private _noMipmap;
  20362. /** @hidden */
  20363. _invertY: boolean;
  20364. private _rowGenerationMatrix;
  20365. private _cachedTextureMatrix;
  20366. private _projectionModeMatrix;
  20367. private _t0;
  20368. private _t1;
  20369. private _t2;
  20370. private _cachedUOffset;
  20371. private _cachedVOffset;
  20372. private _cachedUScale;
  20373. private _cachedVScale;
  20374. private _cachedUAng;
  20375. private _cachedVAng;
  20376. private _cachedWAng;
  20377. private _cachedProjectionMatrixId;
  20378. private _cachedCoordinatesMode;
  20379. /** @hidden */
  20380. protected _initialSamplingMode: number;
  20381. /** @hidden */
  20382. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20383. private _deleteBuffer;
  20384. protected _format: Nullable<number>;
  20385. private _delayedOnLoad;
  20386. private _delayedOnError;
  20387. private _mimeType?;
  20388. /**
  20389. * Observable triggered once the texture has been loaded.
  20390. */
  20391. onLoadObservable: Observable<Texture>;
  20392. protected _isBlocking: boolean;
  20393. /**
  20394. * Is the texture preventing material to render while loading.
  20395. * If false, a default texture will be used instead of the loading one during the preparation step.
  20396. */
  20397. set isBlocking(value: boolean);
  20398. get isBlocking(): boolean;
  20399. /**
  20400. * Get the current sampling mode associated with the texture.
  20401. */
  20402. get samplingMode(): number;
  20403. /**
  20404. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20405. */
  20406. get invertY(): boolean;
  20407. /**
  20408. * Instantiates a new texture.
  20409. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20410. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20411. * @param url defines the url of the picture to load as a texture
  20412. * @param scene defines the scene or engine the texture will belong to
  20413. * @param noMipmap defines if the texture will require mip maps or not
  20414. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20415. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20416. * @param onLoad defines a callback triggered when the texture has been loaded
  20417. * @param onError defines a callback triggered when an error occurred during the loading session
  20418. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20419. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20420. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20421. * @param mimeType defines an optional mime type information
  20422. */
  20423. 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);
  20424. /**
  20425. * Update the url (and optional buffer) of this texture if url was null during construction.
  20426. * @param url the url of the texture
  20427. * @param buffer the buffer of the texture (defaults to null)
  20428. * @param onLoad callback called when the texture is loaded (defaults to null)
  20429. */
  20430. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20431. /**
  20432. * Finish the loading sequence of a texture flagged as delayed load.
  20433. * @hidden
  20434. */
  20435. delayLoad(): void;
  20436. private _prepareRowForTextureGeneration;
  20437. /**
  20438. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20439. * @returns the transform matrix of the texture.
  20440. */
  20441. getTextureMatrix(uBase?: number): Matrix;
  20442. /**
  20443. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20444. * @returns The reflection texture transform
  20445. */
  20446. getReflectionTextureMatrix(): Matrix;
  20447. /**
  20448. * Clones the texture.
  20449. * @returns the cloned texture
  20450. */
  20451. clone(): Texture;
  20452. /**
  20453. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20454. * @returns The JSON representation of the texture
  20455. */
  20456. serialize(): any;
  20457. /**
  20458. * Get the current class name of the texture useful for serialization or dynamic coding.
  20459. * @returns "Texture"
  20460. */
  20461. getClassName(): string;
  20462. /**
  20463. * Dispose the texture and release its associated resources.
  20464. */
  20465. dispose(): void;
  20466. /**
  20467. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20468. * @param parsedTexture Define the JSON representation of the texture
  20469. * @param scene Define the scene the parsed texture should be instantiated in
  20470. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20471. * @returns The parsed texture if successful
  20472. */
  20473. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20474. /**
  20475. * Creates a texture from its base 64 representation.
  20476. * @param data Define the base64 payload without the data: prefix
  20477. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20478. * @param scene Define the scene the texture should belong to
  20479. * @param noMipmap Forces the texture to not create mip map information if true
  20480. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20481. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20482. * @param onLoad define a callback triggered when the texture has been loaded
  20483. * @param onError define a callback triggered when an error occurred during the loading session
  20484. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20485. * @returns the created texture
  20486. */
  20487. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20488. /**
  20489. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20490. * @param data Define the base64 payload without the data: prefix
  20491. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20492. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20493. * @param scene Define the scene the texture should belong to
  20494. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20495. * @param noMipmap Forces the texture to not create mip map information if true
  20496. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20497. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20498. * @param onLoad define a callback triggered when the texture has been loaded
  20499. * @param onError define a callback triggered when an error occurred during the loading session
  20500. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20501. * @returns the created texture
  20502. */
  20503. 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;
  20504. }
  20505. }
  20506. declare module BABYLON {
  20507. /**
  20508. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20509. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20510. */
  20511. export class PostProcessManager {
  20512. private _scene;
  20513. private _indexBuffer;
  20514. private _vertexBuffers;
  20515. /**
  20516. * Creates a new instance PostProcess
  20517. * @param scene The scene that the post process is associated with.
  20518. */
  20519. constructor(scene: Scene);
  20520. private _prepareBuffers;
  20521. private _buildIndexBuffer;
  20522. /**
  20523. * Rebuilds the vertex buffers of the manager.
  20524. * @hidden
  20525. */
  20526. _rebuild(): void;
  20527. /**
  20528. * Prepares a frame to be run through a post process.
  20529. * @param sourceTexture The input texture to the post procesess. (default: null)
  20530. * @param postProcesses An array of post processes to be run. (default: null)
  20531. * @returns True if the post processes were able to be run.
  20532. * @hidden
  20533. */
  20534. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20535. /**
  20536. * Manually render a set of post processes to a texture.
  20537. * @param postProcesses An array of post processes to be run.
  20538. * @param targetTexture The target texture to render to.
  20539. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20540. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20541. * @param lodLevel defines which lod of the texture to render to
  20542. */
  20543. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20544. /**
  20545. * Finalize the result of the output of the postprocesses.
  20546. * @param doNotPresent If true the result will not be displayed to the screen.
  20547. * @param targetTexture The target texture to render to.
  20548. * @param faceIndex The index of the face to bind the target texture to.
  20549. * @param postProcesses The array of post processes to render.
  20550. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20551. * @hidden
  20552. */
  20553. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20554. /**
  20555. * Disposes of the post process manager.
  20556. */
  20557. dispose(): void;
  20558. }
  20559. }
  20560. declare module BABYLON {
  20561. /**
  20562. * This Helps creating a texture that will be created from a camera in your scene.
  20563. * It is basically a dynamic texture that could be used to create special effects for instance.
  20564. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20565. */
  20566. export class RenderTargetTexture extends Texture {
  20567. isCube: boolean;
  20568. /**
  20569. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20570. */
  20571. static readonly REFRESHRATE_RENDER_ONCE: number;
  20572. /**
  20573. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20574. */
  20575. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20576. /**
  20577. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20578. * the central point of your effect and can save a lot of performances.
  20579. */
  20580. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20581. /**
  20582. * Use this predicate to dynamically define the list of mesh you want to render.
  20583. * If set, the renderList property will be overwritten.
  20584. */
  20585. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20586. private _renderList;
  20587. /**
  20588. * Use this list to define the list of mesh you want to render.
  20589. */
  20590. get renderList(): Nullable<Array<AbstractMesh>>;
  20591. set renderList(value: Nullable<Array<AbstractMesh>>);
  20592. /**
  20593. * Use this function to overload the renderList array at rendering time.
  20594. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20595. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20596. * the cube (if the RTT is a cube, else layerOrFace=0).
  20597. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20598. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20599. * hold dummy elements!
  20600. */
  20601. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20602. private _hookArray;
  20603. /**
  20604. * Define if particles should be rendered in your texture.
  20605. */
  20606. renderParticles: boolean;
  20607. /**
  20608. * Define if sprites should be rendered in your texture.
  20609. */
  20610. renderSprites: boolean;
  20611. /**
  20612. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20613. */
  20614. coordinatesMode: number;
  20615. /**
  20616. * Define the camera used to render the texture.
  20617. */
  20618. activeCamera: Nullable<Camera>;
  20619. /**
  20620. * Override the mesh isReady function with your own one.
  20621. */
  20622. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20623. /**
  20624. * Override the render function of the texture with your own one.
  20625. */
  20626. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20627. /**
  20628. * Define if camera post processes should be use while rendering the texture.
  20629. */
  20630. useCameraPostProcesses: boolean;
  20631. /**
  20632. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20633. */
  20634. ignoreCameraViewport: boolean;
  20635. private _postProcessManager;
  20636. private _postProcesses;
  20637. private _resizeObserver;
  20638. /**
  20639. * An event triggered when the texture is unbind.
  20640. */
  20641. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20642. /**
  20643. * An event triggered when the texture is unbind.
  20644. */
  20645. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20646. private _onAfterUnbindObserver;
  20647. /**
  20648. * Set a after unbind callback in the texture.
  20649. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20650. */
  20651. set onAfterUnbind(callback: () => void);
  20652. /**
  20653. * An event triggered before rendering the texture
  20654. */
  20655. onBeforeRenderObservable: Observable<number>;
  20656. private _onBeforeRenderObserver;
  20657. /**
  20658. * Set a before render callback in the texture.
  20659. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20660. */
  20661. set onBeforeRender(callback: (faceIndex: number) => void);
  20662. /**
  20663. * An event triggered after rendering the texture
  20664. */
  20665. onAfterRenderObservable: Observable<number>;
  20666. private _onAfterRenderObserver;
  20667. /**
  20668. * Set a after render callback in the texture.
  20669. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20670. */
  20671. set onAfterRender(callback: (faceIndex: number) => void);
  20672. /**
  20673. * An event triggered after the texture clear
  20674. */
  20675. onClearObservable: Observable<Engine>;
  20676. private _onClearObserver;
  20677. /**
  20678. * Set a clear callback in the texture.
  20679. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20680. */
  20681. set onClear(callback: (Engine: Engine) => void);
  20682. /**
  20683. * An event triggered when the texture is resized.
  20684. */
  20685. onResizeObservable: Observable<RenderTargetTexture>;
  20686. /**
  20687. * Define the clear color of the Render Target if it should be different from the scene.
  20688. */
  20689. clearColor: Color4;
  20690. protected _size: number | {
  20691. width: number;
  20692. height: number;
  20693. layers?: number;
  20694. };
  20695. protected _initialSizeParameter: number | {
  20696. width: number;
  20697. height: number;
  20698. } | {
  20699. ratio: number;
  20700. };
  20701. protected _sizeRatio: Nullable<number>;
  20702. /** @hidden */
  20703. _generateMipMaps: boolean;
  20704. protected _renderingManager: RenderingManager;
  20705. /** @hidden */
  20706. _waitingRenderList: string[];
  20707. protected _doNotChangeAspectRatio: boolean;
  20708. protected _currentRefreshId: number;
  20709. protected _refreshRate: number;
  20710. protected _textureMatrix: Matrix;
  20711. protected _samples: number;
  20712. protected _renderTargetOptions: RenderTargetCreationOptions;
  20713. /**
  20714. * Gets render target creation options that were used.
  20715. */
  20716. get renderTargetOptions(): RenderTargetCreationOptions;
  20717. protected _engine: Engine;
  20718. protected _onRatioRescale(): void;
  20719. /**
  20720. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20721. * It must define where the camera used to render the texture is set
  20722. */
  20723. boundingBoxPosition: Vector3;
  20724. private _boundingBoxSize;
  20725. /**
  20726. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20727. * When defined, the cubemap will switch to local mode
  20728. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20729. * @example https://www.babylonjs-playground.com/#RNASML
  20730. */
  20731. set boundingBoxSize(value: Vector3);
  20732. get boundingBoxSize(): Vector3;
  20733. /**
  20734. * In case the RTT has been created with a depth texture, get the associated
  20735. * depth texture.
  20736. * Otherwise, return null.
  20737. */
  20738. get depthStencilTexture(): Nullable<InternalTexture>;
  20739. /**
  20740. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20741. * or used a shadow, depth texture...
  20742. * @param name The friendly name of the texture
  20743. * @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)
  20744. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20745. * @param generateMipMaps True if mip maps need to be generated after render.
  20746. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20747. * @param type The type of the buffer in the RTT (int, half float, float...)
  20748. * @param isCube True if a cube texture needs to be created
  20749. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20750. * @param generateDepthBuffer True to generate a depth buffer
  20751. * @param generateStencilBuffer True to generate a stencil buffer
  20752. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20753. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20754. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20755. */
  20756. constructor(name: string, size: number | {
  20757. width: number;
  20758. height: number;
  20759. layers?: number;
  20760. } | {
  20761. ratio: number;
  20762. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20763. /**
  20764. * Creates a depth stencil texture.
  20765. * This is only available in WebGL 2 or with the depth texture extension available.
  20766. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20767. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20768. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20769. */
  20770. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20771. private _processSizeParameter;
  20772. /**
  20773. * Define the number of samples to use in case of MSAA.
  20774. * It defaults to one meaning no MSAA has been enabled.
  20775. */
  20776. get samples(): number;
  20777. set samples(value: number);
  20778. /**
  20779. * Resets the refresh counter of the texture and start bak from scratch.
  20780. * Could be useful to regenerate the texture if it is setup to render only once.
  20781. */
  20782. resetRefreshCounter(): void;
  20783. /**
  20784. * Define the refresh rate of the texture or the rendering frequency.
  20785. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20786. */
  20787. get refreshRate(): number;
  20788. set refreshRate(value: number);
  20789. /**
  20790. * Adds a post process to the render target rendering passes.
  20791. * @param postProcess define the post process to add
  20792. */
  20793. addPostProcess(postProcess: PostProcess): void;
  20794. /**
  20795. * Clear all the post processes attached to the render target
  20796. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20797. */
  20798. clearPostProcesses(dispose?: boolean): void;
  20799. /**
  20800. * Remove one of the post process from the list of attached post processes to the texture
  20801. * @param postProcess define the post process to remove from the list
  20802. */
  20803. removePostProcess(postProcess: PostProcess): void;
  20804. /** @hidden */
  20805. _shouldRender(): boolean;
  20806. /**
  20807. * Gets the actual render size of the texture.
  20808. * @returns the width of the render size
  20809. */
  20810. getRenderSize(): number;
  20811. /**
  20812. * Gets the actual render width of the texture.
  20813. * @returns the width of the render size
  20814. */
  20815. getRenderWidth(): number;
  20816. /**
  20817. * Gets the actual render height of the texture.
  20818. * @returns the height of the render size
  20819. */
  20820. getRenderHeight(): number;
  20821. /**
  20822. * Gets the actual number of layers of the texture.
  20823. * @returns the number of layers
  20824. */
  20825. getRenderLayers(): number;
  20826. /**
  20827. * Get if the texture can be rescaled or not.
  20828. */
  20829. get canRescale(): boolean;
  20830. /**
  20831. * Resize the texture using a ratio.
  20832. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20833. */
  20834. scale(ratio: number): void;
  20835. /**
  20836. * Get the texture reflection matrix used to rotate/transform the reflection.
  20837. * @returns the reflection matrix
  20838. */
  20839. getReflectionTextureMatrix(): Matrix;
  20840. /**
  20841. * Resize the texture to a new desired size.
  20842. * Be carrefull as it will recreate all the data in the new texture.
  20843. * @param size Define the new size. It can be:
  20844. * - a number for squared texture,
  20845. * - an object containing { width: number, height: number }
  20846. * - or an object containing a ratio { ratio: number }
  20847. */
  20848. resize(size: number | {
  20849. width: number;
  20850. height: number;
  20851. } | {
  20852. ratio: number;
  20853. }): void;
  20854. private _defaultRenderListPrepared;
  20855. /**
  20856. * Renders all the objects from the render list into the texture.
  20857. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20858. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20859. */
  20860. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20861. private _bestReflectionRenderTargetDimension;
  20862. private _prepareRenderingManager;
  20863. /**
  20864. * @hidden
  20865. * @param faceIndex face index to bind to if this is a cubetexture
  20866. * @param layer defines the index of the texture to bind in the array
  20867. */
  20868. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20869. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20870. private renderToTarget;
  20871. /**
  20872. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20873. * This allowed control for front to back rendering or reversly depending of the special needs.
  20874. *
  20875. * @param renderingGroupId The rendering group id corresponding to its index
  20876. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20877. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20878. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20879. */
  20880. 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;
  20881. /**
  20882. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20883. *
  20884. * @param renderingGroupId The rendering group id corresponding to its index
  20885. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20886. */
  20887. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20888. /**
  20889. * Clones the texture.
  20890. * @returns the cloned texture
  20891. */
  20892. clone(): RenderTargetTexture;
  20893. /**
  20894. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20895. * @returns The JSON representation of the texture
  20896. */
  20897. serialize(): any;
  20898. /**
  20899. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20900. */
  20901. disposeFramebufferObjects(): void;
  20902. /**
  20903. * Dispose the texture and release its associated resources.
  20904. */
  20905. dispose(): void;
  20906. /** @hidden */
  20907. _rebuild(): void;
  20908. /**
  20909. * Clear the info related to rendering groups preventing retention point in material dispose.
  20910. */
  20911. freeRenderingGroups(): void;
  20912. /**
  20913. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20914. * @returns the view count
  20915. */
  20916. getViewCount(): number;
  20917. }
  20918. }
  20919. declare module BABYLON {
  20920. /**
  20921. * Options for compiling materials.
  20922. */
  20923. export interface IMaterialCompilationOptions {
  20924. /**
  20925. * Defines whether clip planes are enabled.
  20926. */
  20927. clipPlane: boolean;
  20928. /**
  20929. * Defines whether instances are enabled.
  20930. */
  20931. useInstances: boolean;
  20932. }
  20933. /**
  20934. * Base class for the main features of a material in Babylon.js
  20935. */
  20936. export class Material implements IAnimatable {
  20937. /**
  20938. * Returns the triangle fill mode
  20939. */
  20940. static readonly TriangleFillMode: number;
  20941. /**
  20942. * Returns the wireframe mode
  20943. */
  20944. static readonly WireFrameFillMode: number;
  20945. /**
  20946. * Returns the point fill mode
  20947. */
  20948. static readonly PointFillMode: number;
  20949. /**
  20950. * Returns the point list draw mode
  20951. */
  20952. static readonly PointListDrawMode: number;
  20953. /**
  20954. * Returns the line list draw mode
  20955. */
  20956. static readonly LineListDrawMode: number;
  20957. /**
  20958. * Returns the line loop draw mode
  20959. */
  20960. static readonly LineLoopDrawMode: number;
  20961. /**
  20962. * Returns the line strip draw mode
  20963. */
  20964. static readonly LineStripDrawMode: number;
  20965. /**
  20966. * Returns the triangle strip draw mode
  20967. */
  20968. static readonly TriangleStripDrawMode: number;
  20969. /**
  20970. * Returns the triangle fan draw mode
  20971. */
  20972. static readonly TriangleFanDrawMode: number;
  20973. /**
  20974. * Stores the clock-wise side orientation
  20975. */
  20976. static readonly ClockWiseSideOrientation: number;
  20977. /**
  20978. * Stores the counter clock-wise side orientation
  20979. */
  20980. static readonly CounterClockWiseSideOrientation: number;
  20981. /**
  20982. * The dirty texture flag value
  20983. */
  20984. static readonly TextureDirtyFlag: number;
  20985. /**
  20986. * The dirty light flag value
  20987. */
  20988. static readonly LightDirtyFlag: number;
  20989. /**
  20990. * The dirty fresnel flag value
  20991. */
  20992. static readonly FresnelDirtyFlag: number;
  20993. /**
  20994. * The dirty attribute flag value
  20995. */
  20996. static readonly AttributesDirtyFlag: number;
  20997. /**
  20998. * The dirty misc flag value
  20999. */
  21000. static readonly MiscDirtyFlag: number;
  21001. /**
  21002. * The all dirty flag value
  21003. */
  21004. static readonly AllDirtyFlag: number;
  21005. /**
  21006. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21007. */
  21008. static readonly MATERIAL_OPAQUE: number;
  21009. /**
  21010. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21011. */
  21012. static readonly MATERIAL_ALPHATEST: number;
  21013. /**
  21014. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21015. */
  21016. static readonly MATERIAL_ALPHABLEND: number;
  21017. /**
  21018. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21019. * They are also discarded below the alpha cutoff threshold to improve performances.
  21020. */
  21021. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21022. /**
  21023. * The ID of the material
  21024. */
  21025. id: string;
  21026. /**
  21027. * Gets or sets the unique id of the material
  21028. */
  21029. uniqueId: number;
  21030. /**
  21031. * The name of the material
  21032. */
  21033. name: string;
  21034. /**
  21035. * Gets or sets user defined metadata
  21036. */
  21037. metadata: any;
  21038. /**
  21039. * For internal use only. Please do not use.
  21040. */
  21041. reservedDataStore: any;
  21042. /**
  21043. * Specifies if the ready state should be checked on each call
  21044. */
  21045. checkReadyOnEveryCall: boolean;
  21046. /**
  21047. * Specifies if the ready state should be checked once
  21048. */
  21049. checkReadyOnlyOnce: boolean;
  21050. /**
  21051. * The state of the material
  21052. */
  21053. state: string;
  21054. /**
  21055. * The alpha value of the material
  21056. */
  21057. protected _alpha: number;
  21058. /**
  21059. * List of inspectable custom properties (used by the Inspector)
  21060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21061. */
  21062. inspectableCustomProperties: IInspectable[];
  21063. /**
  21064. * Sets the alpha value of the material
  21065. */
  21066. set alpha(value: number);
  21067. /**
  21068. * Gets the alpha value of the material
  21069. */
  21070. get alpha(): number;
  21071. /**
  21072. * Specifies if back face culling is enabled
  21073. */
  21074. protected _backFaceCulling: boolean;
  21075. /**
  21076. * Sets the back-face culling state
  21077. */
  21078. set backFaceCulling(value: boolean);
  21079. /**
  21080. * Gets the back-face culling state
  21081. */
  21082. get backFaceCulling(): boolean;
  21083. /**
  21084. * Stores the value for side orientation
  21085. */
  21086. sideOrientation: number;
  21087. /**
  21088. * Callback triggered when the material is compiled
  21089. */
  21090. onCompiled: Nullable<(effect: Effect) => void>;
  21091. /**
  21092. * Callback triggered when an error occurs
  21093. */
  21094. onError: Nullable<(effect: Effect, errors: string) => void>;
  21095. /**
  21096. * Callback triggered to get the render target textures
  21097. */
  21098. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21099. /**
  21100. * Gets a boolean indicating that current material needs to register RTT
  21101. */
  21102. get hasRenderTargetTextures(): boolean;
  21103. /**
  21104. * Specifies if the material should be serialized
  21105. */
  21106. doNotSerialize: boolean;
  21107. /**
  21108. * @hidden
  21109. */
  21110. _storeEffectOnSubMeshes: boolean;
  21111. /**
  21112. * Stores the animations for the material
  21113. */
  21114. animations: Nullable<Array<Animation>>;
  21115. /**
  21116. * An event triggered when the material is disposed
  21117. */
  21118. onDisposeObservable: Observable<Material>;
  21119. /**
  21120. * An observer which watches for dispose events
  21121. */
  21122. private _onDisposeObserver;
  21123. private _onUnBindObservable;
  21124. /**
  21125. * Called during a dispose event
  21126. */
  21127. set onDispose(callback: () => void);
  21128. private _onBindObservable;
  21129. /**
  21130. * An event triggered when the material is bound
  21131. */
  21132. get onBindObservable(): Observable<AbstractMesh>;
  21133. /**
  21134. * An observer which watches for bind events
  21135. */
  21136. private _onBindObserver;
  21137. /**
  21138. * Called during a bind event
  21139. */
  21140. set onBind(callback: (Mesh: AbstractMesh) => void);
  21141. /**
  21142. * An event triggered when the material is unbound
  21143. */
  21144. get onUnBindObservable(): Observable<Material>;
  21145. /**
  21146. * Stores the value of the alpha mode
  21147. */
  21148. private _alphaMode;
  21149. /**
  21150. * Sets the value of the alpha mode.
  21151. *
  21152. * | Value | Type | Description |
  21153. * | --- | --- | --- |
  21154. * | 0 | ALPHA_DISABLE | |
  21155. * | 1 | ALPHA_ADD | |
  21156. * | 2 | ALPHA_COMBINE | |
  21157. * | 3 | ALPHA_SUBTRACT | |
  21158. * | 4 | ALPHA_MULTIPLY | |
  21159. * | 5 | ALPHA_MAXIMIZED | |
  21160. * | 6 | ALPHA_ONEONE | |
  21161. * | 7 | ALPHA_PREMULTIPLIED | |
  21162. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21163. * | 9 | ALPHA_INTERPOLATE | |
  21164. * | 10 | ALPHA_SCREENMODE | |
  21165. *
  21166. */
  21167. set alphaMode(value: number);
  21168. /**
  21169. * Gets the value of the alpha mode
  21170. */
  21171. get alphaMode(): number;
  21172. /**
  21173. * Stores the state of the need depth pre-pass value
  21174. */
  21175. private _needDepthPrePass;
  21176. /**
  21177. * Sets the need depth pre-pass value
  21178. */
  21179. set needDepthPrePass(value: boolean);
  21180. /**
  21181. * Gets the depth pre-pass value
  21182. */
  21183. get needDepthPrePass(): boolean;
  21184. /**
  21185. * Specifies if depth writing should be disabled
  21186. */
  21187. disableDepthWrite: boolean;
  21188. /**
  21189. * Specifies if depth writing should be forced
  21190. */
  21191. forceDepthWrite: boolean;
  21192. /**
  21193. * Specifies the depth function that should be used. 0 means the default engine function
  21194. */
  21195. depthFunction: number;
  21196. /**
  21197. * Specifies if there should be a separate pass for culling
  21198. */
  21199. separateCullingPass: boolean;
  21200. /**
  21201. * Stores the state specifing if fog should be enabled
  21202. */
  21203. private _fogEnabled;
  21204. /**
  21205. * Sets the state for enabling fog
  21206. */
  21207. set fogEnabled(value: boolean);
  21208. /**
  21209. * Gets the value of the fog enabled state
  21210. */
  21211. get fogEnabled(): boolean;
  21212. /**
  21213. * Stores the size of points
  21214. */
  21215. pointSize: number;
  21216. /**
  21217. * Stores the z offset value
  21218. */
  21219. zOffset: number;
  21220. /**
  21221. * Gets a value specifying if wireframe mode is enabled
  21222. */
  21223. get wireframe(): boolean;
  21224. /**
  21225. * Sets the state of wireframe mode
  21226. */
  21227. set wireframe(value: boolean);
  21228. /**
  21229. * Gets the value specifying if point clouds are enabled
  21230. */
  21231. get pointsCloud(): boolean;
  21232. /**
  21233. * Sets the state of point cloud mode
  21234. */
  21235. set pointsCloud(value: boolean);
  21236. /**
  21237. * Gets the material fill mode
  21238. */
  21239. get fillMode(): number;
  21240. /**
  21241. * Sets the material fill mode
  21242. */
  21243. set fillMode(value: number);
  21244. /**
  21245. * @hidden
  21246. * Stores the effects for the material
  21247. */
  21248. _effect: Nullable<Effect>;
  21249. /**
  21250. * Specifies if uniform buffers should be used
  21251. */
  21252. private _useUBO;
  21253. /**
  21254. * Stores a reference to the scene
  21255. */
  21256. private _scene;
  21257. /**
  21258. * Stores the fill mode state
  21259. */
  21260. private _fillMode;
  21261. /**
  21262. * Specifies if the depth write state should be cached
  21263. */
  21264. private _cachedDepthWriteState;
  21265. /**
  21266. * Specifies if the depth function state should be cached
  21267. */
  21268. private _cachedDepthFunctionState;
  21269. /**
  21270. * Stores the uniform buffer
  21271. */
  21272. protected _uniformBuffer: UniformBuffer;
  21273. /** @hidden */
  21274. _indexInSceneMaterialArray: number;
  21275. /** @hidden */
  21276. meshMap: Nullable<{
  21277. [id: string]: AbstractMesh | undefined;
  21278. }>;
  21279. /**
  21280. * Creates a material instance
  21281. * @param name defines the name of the material
  21282. * @param scene defines the scene to reference
  21283. * @param doNotAdd specifies if the material should be added to the scene
  21284. */
  21285. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21286. /**
  21287. * Returns a string representation of the current material
  21288. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21289. * @returns a string with material information
  21290. */
  21291. toString(fullDetails?: boolean): string;
  21292. /**
  21293. * Gets the class name of the material
  21294. * @returns a string with the class name of the material
  21295. */
  21296. getClassName(): string;
  21297. /**
  21298. * Specifies if updates for the material been locked
  21299. */
  21300. get isFrozen(): boolean;
  21301. /**
  21302. * Locks updates for the material
  21303. */
  21304. freeze(): void;
  21305. /**
  21306. * Unlocks updates for the material
  21307. */
  21308. unfreeze(): void;
  21309. /**
  21310. * Specifies if the material is ready to be used
  21311. * @param mesh defines the mesh to check
  21312. * @param useInstances specifies if instances should be used
  21313. * @returns a boolean indicating if the material is ready to be used
  21314. */
  21315. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21316. /**
  21317. * Specifies that the submesh is ready to be used
  21318. * @param mesh defines the mesh to check
  21319. * @param subMesh defines which submesh to check
  21320. * @param useInstances specifies that instances should be used
  21321. * @returns a boolean indicating that the submesh is ready or not
  21322. */
  21323. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21324. /**
  21325. * Returns the material effect
  21326. * @returns the effect associated with the material
  21327. */
  21328. getEffect(): Nullable<Effect>;
  21329. /**
  21330. * Returns the current scene
  21331. * @returns a Scene
  21332. */
  21333. getScene(): Scene;
  21334. /**
  21335. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21336. */
  21337. protected _forceAlphaTest: boolean;
  21338. /**
  21339. * The transparency mode of the material.
  21340. */
  21341. protected _transparencyMode: Nullable<number>;
  21342. /**
  21343. * Gets the current transparency mode.
  21344. */
  21345. get transparencyMode(): Nullable<number>;
  21346. /**
  21347. * Sets the transparency mode of the material.
  21348. *
  21349. * | Value | Type | Description |
  21350. * | ----- | ----------------------------------- | ----------- |
  21351. * | 0 | OPAQUE | |
  21352. * | 1 | ALPHATEST | |
  21353. * | 2 | ALPHABLEND | |
  21354. * | 3 | ALPHATESTANDBLEND | |
  21355. *
  21356. */
  21357. set transparencyMode(value: Nullable<number>);
  21358. /**
  21359. * Returns true if alpha blending should be disabled.
  21360. */
  21361. protected get _disableAlphaBlending(): boolean;
  21362. /**
  21363. * Specifies whether or not this material should be rendered in alpha blend mode.
  21364. * @returns a boolean specifying if alpha blending is needed
  21365. */
  21366. needAlphaBlending(): boolean;
  21367. /**
  21368. * Specifies if the mesh will require alpha blending
  21369. * @param mesh defines the mesh to check
  21370. * @returns a boolean specifying if alpha blending is needed for the mesh
  21371. */
  21372. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21373. /**
  21374. * Specifies whether or not this material should be rendered in alpha test mode.
  21375. * @returns a boolean specifying if an alpha test is needed.
  21376. */
  21377. needAlphaTesting(): boolean;
  21378. /**
  21379. * Specifies if material alpha testing should be turned on for the mesh
  21380. * @param mesh defines the mesh to check
  21381. */
  21382. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21383. /**
  21384. * Gets the texture used for the alpha test
  21385. * @returns the texture to use for alpha testing
  21386. */
  21387. getAlphaTestTexture(): Nullable<BaseTexture>;
  21388. /**
  21389. * Marks the material to indicate that it needs to be re-calculated
  21390. */
  21391. markDirty(): void;
  21392. /** @hidden */
  21393. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21394. /**
  21395. * Binds the material to the mesh
  21396. * @param world defines the world transformation matrix
  21397. * @param mesh defines the mesh to bind the material to
  21398. */
  21399. bind(world: Matrix, mesh?: Mesh): void;
  21400. /**
  21401. * Binds the submesh to the material
  21402. * @param world defines the world transformation matrix
  21403. * @param mesh defines the mesh containing the submesh
  21404. * @param subMesh defines the submesh to bind the material to
  21405. */
  21406. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21407. /**
  21408. * Binds the world matrix to the material
  21409. * @param world defines the world transformation matrix
  21410. */
  21411. bindOnlyWorldMatrix(world: Matrix): void;
  21412. /**
  21413. * Binds the scene's uniform buffer to the effect.
  21414. * @param effect defines the effect to bind to the scene uniform buffer
  21415. * @param sceneUbo defines the uniform buffer storing scene data
  21416. */
  21417. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21418. /**
  21419. * Binds the view matrix to the effect
  21420. * @param effect defines the effect to bind the view matrix to
  21421. */
  21422. bindView(effect: Effect): void;
  21423. /**
  21424. * Binds the view projection matrix to the effect
  21425. * @param effect defines the effect to bind the view projection matrix to
  21426. */
  21427. bindViewProjection(effect: Effect): void;
  21428. /**
  21429. * Processes to execute after binding the material to a mesh
  21430. * @param mesh defines the rendered mesh
  21431. */
  21432. protected _afterBind(mesh?: Mesh): void;
  21433. /**
  21434. * Unbinds the material from the mesh
  21435. */
  21436. unbind(): void;
  21437. /**
  21438. * Gets the active textures from the material
  21439. * @returns an array of textures
  21440. */
  21441. getActiveTextures(): BaseTexture[];
  21442. /**
  21443. * Specifies if the material uses a texture
  21444. * @param texture defines the texture to check against the material
  21445. * @returns a boolean specifying if the material uses the texture
  21446. */
  21447. hasTexture(texture: BaseTexture): boolean;
  21448. /**
  21449. * Makes a duplicate of the material, and gives it a new name
  21450. * @param name defines the new name for the duplicated material
  21451. * @returns the cloned material
  21452. */
  21453. clone(name: string): Nullable<Material>;
  21454. /**
  21455. * Gets the meshes bound to the material
  21456. * @returns an array of meshes bound to the material
  21457. */
  21458. getBindedMeshes(): AbstractMesh[];
  21459. /**
  21460. * Force shader compilation
  21461. * @param mesh defines the mesh associated with this material
  21462. * @param onCompiled defines a function to execute once the material is compiled
  21463. * @param options defines the options to configure the compilation
  21464. * @param onError defines a function to execute if the material fails compiling
  21465. */
  21466. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21467. /**
  21468. * Force shader compilation
  21469. * @param mesh defines the mesh that will use this material
  21470. * @param options defines additional options for compiling the shaders
  21471. * @returns a promise that resolves when the compilation completes
  21472. */
  21473. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21474. private static readonly _AllDirtyCallBack;
  21475. private static readonly _ImageProcessingDirtyCallBack;
  21476. private static readonly _TextureDirtyCallBack;
  21477. private static readonly _FresnelDirtyCallBack;
  21478. private static readonly _MiscDirtyCallBack;
  21479. private static readonly _LightsDirtyCallBack;
  21480. private static readonly _AttributeDirtyCallBack;
  21481. private static _FresnelAndMiscDirtyCallBack;
  21482. private static _TextureAndMiscDirtyCallBack;
  21483. private static readonly _DirtyCallbackArray;
  21484. private static readonly _RunDirtyCallBacks;
  21485. /**
  21486. * Marks a define in the material to indicate that it needs to be re-computed
  21487. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21488. */
  21489. markAsDirty(flag: number): void;
  21490. /**
  21491. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21492. * @param func defines a function which checks material defines against the submeshes
  21493. */
  21494. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21495. /**
  21496. * Indicates that we need to re-calculated for all submeshes
  21497. */
  21498. protected _markAllSubMeshesAsAllDirty(): void;
  21499. /**
  21500. * Indicates that image processing needs to be re-calculated for all submeshes
  21501. */
  21502. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21503. /**
  21504. * Indicates that textures need to be re-calculated for all submeshes
  21505. */
  21506. protected _markAllSubMeshesAsTexturesDirty(): void;
  21507. /**
  21508. * Indicates that fresnel needs to be re-calculated for all submeshes
  21509. */
  21510. protected _markAllSubMeshesAsFresnelDirty(): void;
  21511. /**
  21512. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21513. */
  21514. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21515. /**
  21516. * Indicates that lights need to be re-calculated for all submeshes
  21517. */
  21518. protected _markAllSubMeshesAsLightsDirty(): void;
  21519. /**
  21520. * Indicates that attributes need to be re-calculated for all submeshes
  21521. */
  21522. protected _markAllSubMeshesAsAttributesDirty(): void;
  21523. /**
  21524. * Indicates that misc needs to be re-calculated for all submeshes
  21525. */
  21526. protected _markAllSubMeshesAsMiscDirty(): void;
  21527. /**
  21528. * Indicates that textures and misc need to be re-calculated for all submeshes
  21529. */
  21530. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21531. /**
  21532. * Disposes the material
  21533. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21534. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21535. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21536. */
  21537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21538. /** @hidden */
  21539. private releaseVertexArrayObject;
  21540. /**
  21541. * Serializes this material
  21542. * @returns the serialized material object
  21543. */
  21544. serialize(): any;
  21545. /**
  21546. * Creates a material from parsed material data
  21547. * @param parsedMaterial defines parsed material data
  21548. * @param scene defines the hosting scene
  21549. * @param rootUrl defines the root URL to use to load textures
  21550. * @returns a new material
  21551. */
  21552. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21553. }
  21554. }
  21555. declare module BABYLON {
  21556. /**
  21557. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21558. * separate meshes. This can be use to improve performances.
  21559. * @see http://doc.babylonjs.com/how_to/multi_materials
  21560. */
  21561. export class MultiMaterial extends Material {
  21562. private _subMaterials;
  21563. /**
  21564. * Gets or Sets the list of Materials used within the multi material.
  21565. * They need to be ordered according to the submeshes order in the associated mesh
  21566. */
  21567. get subMaterials(): Nullable<Material>[];
  21568. set subMaterials(value: Nullable<Material>[]);
  21569. /**
  21570. * Function used to align with Node.getChildren()
  21571. * @returns the list of Materials used within the multi material
  21572. */
  21573. getChildren(): Nullable<Material>[];
  21574. /**
  21575. * Instantiates a new Multi Material
  21576. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21577. * separate meshes. This can be use to improve performances.
  21578. * @see http://doc.babylonjs.com/how_to/multi_materials
  21579. * @param name Define the name in the scene
  21580. * @param scene Define the scene the material belongs to
  21581. */
  21582. constructor(name: string, scene: Scene);
  21583. private _hookArray;
  21584. /**
  21585. * Get one of the submaterial by its index in the submaterials array
  21586. * @param index The index to look the sub material at
  21587. * @returns The Material if the index has been defined
  21588. */
  21589. getSubMaterial(index: number): Nullable<Material>;
  21590. /**
  21591. * Get the list of active textures for the whole sub materials list.
  21592. * @returns All the textures that will be used during the rendering
  21593. */
  21594. getActiveTextures(): BaseTexture[];
  21595. /**
  21596. * Gets the current class name of the material e.g. "MultiMaterial"
  21597. * Mainly use in serialization.
  21598. * @returns the class name
  21599. */
  21600. getClassName(): string;
  21601. /**
  21602. * Checks if the material is ready to render the requested sub mesh
  21603. * @param mesh Define the mesh the submesh belongs to
  21604. * @param subMesh Define the sub mesh to look readyness for
  21605. * @param useInstances Define whether or not the material is used with instances
  21606. * @returns true if ready, otherwise false
  21607. */
  21608. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21609. /**
  21610. * Clones the current material and its related sub materials
  21611. * @param name Define the name of the newly cloned material
  21612. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21613. * @returns the cloned material
  21614. */
  21615. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21616. /**
  21617. * Serializes the materials into a JSON representation.
  21618. * @returns the JSON representation
  21619. */
  21620. serialize(): any;
  21621. /**
  21622. * Dispose the material and release its associated resources
  21623. * @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)
  21624. * @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)
  21625. * @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)
  21626. */
  21627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21628. /**
  21629. * Creates a MultiMaterial from parsed MultiMaterial data.
  21630. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21631. * @param scene defines the hosting scene
  21632. * @returns a new MultiMaterial
  21633. */
  21634. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21635. }
  21636. }
  21637. declare module BABYLON {
  21638. /**
  21639. * Base class for submeshes
  21640. */
  21641. export class BaseSubMesh {
  21642. /** @hidden */
  21643. _materialDefines: Nullable<MaterialDefines>;
  21644. /** @hidden */
  21645. _materialEffect: Nullable<Effect>;
  21646. /**
  21647. * Gets material defines used by the effect associated to the sub mesh
  21648. */
  21649. get materialDefines(): Nullable<MaterialDefines>;
  21650. /**
  21651. * Sets material defines used by the effect associated to the sub mesh
  21652. */
  21653. set materialDefines(defines: Nullable<MaterialDefines>);
  21654. /**
  21655. * Gets associated effect
  21656. */
  21657. get effect(): Nullable<Effect>;
  21658. /**
  21659. * Sets associated effect (effect used to render this submesh)
  21660. * @param effect defines the effect to associate with
  21661. * @param defines defines the set of defines used to compile this effect
  21662. */
  21663. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21664. }
  21665. /**
  21666. * Defines a subdivision inside a mesh
  21667. */
  21668. export class SubMesh extends BaseSubMesh implements ICullable {
  21669. /** the material index to use */
  21670. materialIndex: number;
  21671. /** vertex index start */
  21672. verticesStart: number;
  21673. /** vertices count */
  21674. verticesCount: number;
  21675. /** index start */
  21676. indexStart: number;
  21677. /** indices count */
  21678. indexCount: number;
  21679. /** @hidden */
  21680. _linesIndexCount: number;
  21681. private _mesh;
  21682. private _renderingMesh;
  21683. private _boundingInfo;
  21684. private _linesIndexBuffer;
  21685. /** @hidden */
  21686. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21687. /** @hidden */
  21688. _trianglePlanes: Plane[];
  21689. /** @hidden */
  21690. _lastColliderTransformMatrix: Nullable<Matrix>;
  21691. /** @hidden */
  21692. _renderId: number;
  21693. /** @hidden */
  21694. _alphaIndex: number;
  21695. /** @hidden */
  21696. _distanceToCamera: number;
  21697. /** @hidden */
  21698. _id: number;
  21699. private _currentMaterial;
  21700. /**
  21701. * Add a new submesh to a mesh
  21702. * @param materialIndex defines the material index to use
  21703. * @param verticesStart defines vertex index start
  21704. * @param verticesCount defines vertices count
  21705. * @param indexStart defines index start
  21706. * @param indexCount defines indices count
  21707. * @param mesh defines the parent mesh
  21708. * @param renderingMesh defines an optional rendering mesh
  21709. * @param createBoundingBox defines if bounding box should be created for this submesh
  21710. * @returns the new submesh
  21711. */
  21712. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21713. /**
  21714. * Creates a new submesh
  21715. * @param materialIndex defines the material index to use
  21716. * @param verticesStart defines vertex index start
  21717. * @param verticesCount defines vertices count
  21718. * @param indexStart defines index start
  21719. * @param indexCount defines indices count
  21720. * @param mesh defines the parent mesh
  21721. * @param renderingMesh defines an optional rendering mesh
  21722. * @param createBoundingBox defines if bounding box should be created for this submesh
  21723. */
  21724. constructor(
  21725. /** the material index to use */
  21726. materialIndex: number,
  21727. /** vertex index start */
  21728. verticesStart: number,
  21729. /** vertices count */
  21730. verticesCount: number,
  21731. /** index start */
  21732. indexStart: number,
  21733. /** indices count */
  21734. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21735. /**
  21736. * Returns true if this submesh covers the entire parent mesh
  21737. * @ignorenaming
  21738. */
  21739. get IsGlobal(): boolean;
  21740. /**
  21741. * Returns the submesh BoudingInfo object
  21742. * @returns current bounding info (or mesh's one if the submesh is global)
  21743. */
  21744. getBoundingInfo(): BoundingInfo;
  21745. /**
  21746. * Sets the submesh BoundingInfo
  21747. * @param boundingInfo defines the new bounding info to use
  21748. * @returns the SubMesh
  21749. */
  21750. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21751. /**
  21752. * Returns the mesh of the current submesh
  21753. * @return the parent mesh
  21754. */
  21755. getMesh(): AbstractMesh;
  21756. /**
  21757. * Returns the rendering mesh of the submesh
  21758. * @returns the rendering mesh (could be different from parent mesh)
  21759. */
  21760. getRenderingMesh(): Mesh;
  21761. /**
  21762. * Returns the submesh material
  21763. * @returns null or the current material
  21764. */
  21765. getMaterial(): Nullable<Material>;
  21766. /**
  21767. * Sets a new updated BoundingInfo object to the submesh
  21768. * @param data defines an optional position array to use to determine the bounding info
  21769. * @returns the SubMesh
  21770. */
  21771. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21772. /** @hidden */
  21773. _checkCollision(collider: Collider): boolean;
  21774. /**
  21775. * Updates the submesh BoundingInfo
  21776. * @param world defines the world matrix to use to update the bounding info
  21777. * @returns the submesh
  21778. */
  21779. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21780. /**
  21781. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21782. * @param frustumPlanes defines the frustum planes
  21783. * @returns true if the submesh is intersecting with the frustum
  21784. */
  21785. isInFrustum(frustumPlanes: Plane[]): boolean;
  21786. /**
  21787. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21788. * @param frustumPlanes defines the frustum planes
  21789. * @returns true if the submesh is inside the frustum
  21790. */
  21791. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21792. /**
  21793. * Renders the submesh
  21794. * @param enableAlphaMode defines if alpha needs to be used
  21795. * @returns the submesh
  21796. */
  21797. render(enableAlphaMode: boolean): SubMesh;
  21798. /**
  21799. * @hidden
  21800. */
  21801. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21802. /**
  21803. * Checks if the submesh intersects with a ray
  21804. * @param ray defines the ray to test
  21805. * @returns true is the passed ray intersects the submesh bounding box
  21806. */
  21807. canIntersects(ray: Ray): boolean;
  21808. /**
  21809. * Intersects current submesh with a ray
  21810. * @param ray defines the ray to test
  21811. * @param positions defines mesh's positions array
  21812. * @param indices defines mesh's indices array
  21813. * @param fastCheck defines if only bounding info should be used
  21814. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21815. * @returns intersection info or null if no intersection
  21816. */
  21817. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21818. /** @hidden */
  21819. private _intersectLines;
  21820. /** @hidden */
  21821. private _intersectUnIndexedLines;
  21822. /** @hidden */
  21823. private _intersectTriangles;
  21824. /** @hidden */
  21825. private _intersectUnIndexedTriangles;
  21826. /** @hidden */
  21827. _rebuild(): void;
  21828. /**
  21829. * Creates a new submesh from the passed mesh
  21830. * @param newMesh defines the new hosting mesh
  21831. * @param newRenderingMesh defines an optional rendering mesh
  21832. * @returns the new submesh
  21833. */
  21834. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21835. /**
  21836. * Release associated resources
  21837. */
  21838. dispose(): void;
  21839. /**
  21840. * Gets the class name
  21841. * @returns the string "SubMesh".
  21842. */
  21843. getClassName(): string;
  21844. /**
  21845. * Creates a new submesh from indices data
  21846. * @param materialIndex the index of the main mesh material
  21847. * @param startIndex the index where to start the copy in the mesh indices array
  21848. * @param indexCount the number of indices to copy then from the startIndex
  21849. * @param mesh the main mesh to create the submesh from
  21850. * @param renderingMesh the optional rendering mesh
  21851. * @returns a new submesh
  21852. */
  21853. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21854. }
  21855. }
  21856. declare module BABYLON {
  21857. /**
  21858. * Class used to represent data loading progression
  21859. */
  21860. export class SceneLoaderFlags {
  21861. private static _ForceFullSceneLoadingForIncremental;
  21862. private static _ShowLoadingScreen;
  21863. private static _CleanBoneMatrixWeights;
  21864. private static _loggingLevel;
  21865. /**
  21866. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21867. */
  21868. static get ForceFullSceneLoadingForIncremental(): boolean;
  21869. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21870. /**
  21871. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21872. */
  21873. static get ShowLoadingScreen(): boolean;
  21874. static set ShowLoadingScreen(value: boolean);
  21875. /**
  21876. * Defines the current logging level (while loading the scene)
  21877. * @ignorenaming
  21878. */
  21879. static get loggingLevel(): number;
  21880. static set loggingLevel(value: number);
  21881. /**
  21882. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21883. */
  21884. static get CleanBoneMatrixWeights(): boolean;
  21885. static set CleanBoneMatrixWeights(value: boolean);
  21886. }
  21887. }
  21888. declare module BABYLON {
  21889. /**
  21890. * Class used to store geometry data (vertex buffers + index buffer)
  21891. */
  21892. export class Geometry implements IGetSetVerticesData {
  21893. /**
  21894. * Gets or sets the ID of the geometry
  21895. */
  21896. id: string;
  21897. /**
  21898. * Gets or sets the unique ID of the geometry
  21899. */
  21900. uniqueId: number;
  21901. /**
  21902. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21903. */
  21904. delayLoadState: number;
  21905. /**
  21906. * Gets the file containing the data to load when running in delay load state
  21907. */
  21908. delayLoadingFile: Nullable<string>;
  21909. /**
  21910. * Callback called when the geometry is updated
  21911. */
  21912. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21913. private _scene;
  21914. private _engine;
  21915. private _meshes;
  21916. private _totalVertices;
  21917. /** @hidden */
  21918. _indices: IndicesArray;
  21919. /** @hidden */
  21920. _vertexBuffers: {
  21921. [key: string]: VertexBuffer;
  21922. };
  21923. private _isDisposed;
  21924. private _extend;
  21925. private _boundingBias;
  21926. /** @hidden */
  21927. _delayInfo: Array<string>;
  21928. private _indexBuffer;
  21929. private _indexBufferIsUpdatable;
  21930. /** @hidden */
  21931. _boundingInfo: Nullable<BoundingInfo>;
  21932. /** @hidden */
  21933. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21934. /** @hidden */
  21935. _softwareSkinningFrameId: number;
  21936. private _vertexArrayObjects;
  21937. private _updatable;
  21938. /** @hidden */
  21939. _positions: Nullable<Vector3[]>;
  21940. /**
  21941. * 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
  21942. */
  21943. get boundingBias(): Vector2;
  21944. /**
  21945. * 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
  21946. */
  21947. set boundingBias(value: Vector2);
  21948. /**
  21949. * Static function used to attach a new empty geometry to a mesh
  21950. * @param mesh defines the mesh to attach the geometry to
  21951. * @returns the new Geometry
  21952. */
  21953. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21954. /**
  21955. * Creates a new geometry
  21956. * @param id defines the unique ID
  21957. * @param scene defines the hosting scene
  21958. * @param vertexData defines the VertexData used to get geometry data
  21959. * @param updatable defines if geometry must be updatable (false by default)
  21960. * @param mesh defines the mesh that will be associated with the geometry
  21961. */
  21962. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21963. /**
  21964. * Gets the current extend of the geometry
  21965. */
  21966. get extend(): {
  21967. minimum: Vector3;
  21968. maximum: Vector3;
  21969. };
  21970. /**
  21971. * Gets the hosting scene
  21972. * @returns the hosting Scene
  21973. */
  21974. getScene(): Scene;
  21975. /**
  21976. * Gets the hosting engine
  21977. * @returns the hosting Engine
  21978. */
  21979. getEngine(): Engine;
  21980. /**
  21981. * Defines if the geometry is ready to use
  21982. * @returns true if the geometry is ready to be used
  21983. */
  21984. isReady(): boolean;
  21985. /**
  21986. * Gets a value indicating that the geometry should not be serialized
  21987. */
  21988. get doNotSerialize(): boolean;
  21989. /** @hidden */
  21990. _rebuild(): void;
  21991. /**
  21992. * Affects all geometry data in one call
  21993. * @param vertexData defines the geometry data
  21994. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21995. */
  21996. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21997. /**
  21998. * Set specific vertex data
  21999. * @param kind defines the data kind (Position, normal, etc...)
  22000. * @param data defines the vertex data to use
  22001. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22002. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22003. */
  22004. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22005. /**
  22006. * Removes a specific vertex data
  22007. * @param kind defines the data kind (Position, normal, etc...)
  22008. */
  22009. removeVerticesData(kind: string): void;
  22010. /**
  22011. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22012. * @param buffer defines the vertex buffer to use
  22013. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22014. */
  22015. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22016. /**
  22017. * Update a specific vertex buffer
  22018. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22019. * It will do nothing if the buffer is not updatable
  22020. * @param kind defines the data kind (Position, normal, etc...)
  22021. * @param data defines the data to use
  22022. * @param offset defines the offset in the target buffer where to store the data
  22023. * @param useBytes set to true if the offset is in bytes
  22024. */
  22025. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22026. /**
  22027. * Update a specific vertex buffer
  22028. * This function will create a new buffer if the current one is not updatable
  22029. * @param kind defines the data kind (Position, normal, etc...)
  22030. * @param data defines the data to use
  22031. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22032. */
  22033. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22034. private _updateBoundingInfo;
  22035. /** @hidden */
  22036. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22037. /**
  22038. * Gets total number of vertices
  22039. * @returns the total number of vertices
  22040. */
  22041. getTotalVertices(): number;
  22042. /**
  22043. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22044. * @param kind defines the data kind (Position, normal, etc...)
  22045. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22046. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22047. * @returns a float array containing vertex data
  22048. */
  22049. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22050. /**
  22051. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22052. * @param kind defines the data kind (Position, normal, etc...)
  22053. * @returns true if the vertex buffer with the specified kind is updatable
  22054. */
  22055. isVertexBufferUpdatable(kind: string): boolean;
  22056. /**
  22057. * Gets a specific vertex buffer
  22058. * @param kind defines the data kind (Position, normal, etc...)
  22059. * @returns a VertexBuffer
  22060. */
  22061. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22062. /**
  22063. * Returns all vertex buffers
  22064. * @return an object holding all vertex buffers indexed by kind
  22065. */
  22066. getVertexBuffers(): Nullable<{
  22067. [key: string]: VertexBuffer;
  22068. }>;
  22069. /**
  22070. * Gets a boolean indicating if specific vertex buffer is present
  22071. * @param kind defines the data kind (Position, normal, etc...)
  22072. * @returns true if data is present
  22073. */
  22074. isVerticesDataPresent(kind: string): boolean;
  22075. /**
  22076. * Gets a list of all attached data kinds (Position, normal, etc...)
  22077. * @returns a list of string containing all kinds
  22078. */
  22079. getVerticesDataKinds(): string[];
  22080. /**
  22081. * Update index buffer
  22082. * @param indices defines the indices to store in the index buffer
  22083. * @param offset defines the offset in the target buffer where to store the data
  22084. * @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)
  22085. */
  22086. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22087. /**
  22088. * Creates a new index buffer
  22089. * @param indices defines the indices to store in the index buffer
  22090. * @param totalVertices defines the total number of vertices (could be null)
  22091. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22092. */
  22093. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22094. /**
  22095. * Return the total number of indices
  22096. * @returns the total number of indices
  22097. */
  22098. getTotalIndices(): number;
  22099. /**
  22100. * Gets the index buffer array
  22101. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22102. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22103. * @returns the index buffer array
  22104. */
  22105. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22106. /**
  22107. * Gets the index buffer
  22108. * @return the index buffer
  22109. */
  22110. getIndexBuffer(): Nullable<DataBuffer>;
  22111. /** @hidden */
  22112. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22113. /**
  22114. * Release the associated resources for a specific mesh
  22115. * @param mesh defines the source mesh
  22116. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22117. */
  22118. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22119. /**
  22120. * Apply current geometry to a given mesh
  22121. * @param mesh defines the mesh to apply geometry to
  22122. */
  22123. applyToMesh(mesh: Mesh): void;
  22124. private _updateExtend;
  22125. private _applyToMesh;
  22126. private notifyUpdate;
  22127. /**
  22128. * Load the geometry if it was flagged as delay loaded
  22129. * @param scene defines the hosting scene
  22130. * @param onLoaded defines a callback called when the geometry is loaded
  22131. */
  22132. load(scene: Scene, onLoaded?: () => void): void;
  22133. private _queueLoad;
  22134. /**
  22135. * Invert the geometry to move from a right handed system to a left handed one.
  22136. */
  22137. toLeftHanded(): void;
  22138. /** @hidden */
  22139. _resetPointsArrayCache(): void;
  22140. /** @hidden */
  22141. _generatePointsArray(): boolean;
  22142. /**
  22143. * Gets a value indicating if the geometry is disposed
  22144. * @returns true if the geometry was disposed
  22145. */
  22146. isDisposed(): boolean;
  22147. private _disposeVertexArrayObjects;
  22148. /**
  22149. * Free all associated resources
  22150. */
  22151. dispose(): void;
  22152. /**
  22153. * Clone the current geometry into a new geometry
  22154. * @param id defines the unique ID of the new geometry
  22155. * @returns a new geometry object
  22156. */
  22157. copy(id: string): Geometry;
  22158. /**
  22159. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22160. * @return a JSON representation of the current geometry data (without the vertices data)
  22161. */
  22162. serialize(): any;
  22163. private toNumberArray;
  22164. /**
  22165. * Serialize all vertices data into a JSON oject
  22166. * @returns a JSON representation of the current geometry data
  22167. */
  22168. serializeVerticeData(): any;
  22169. /**
  22170. * Extracts a clone of a mesh geometry
  22171. * @param mesh defines the source mesh
  22172. * @param id defines the unique ID of the new geometry object
  22173. * @returns the new geometry object
  22174. */
  22175. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22176. /**
  22177. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22178. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22179. * Be aware Math.random() could cause collisions, but:
  22180. * "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"
  22181. * @returns a string containing a new GUID
  22182. */
  22183. static RandomId(): string;
  22184. /** @hidden */
  22185. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22186. private static _CleanMatricesWeights;
  22187. /**
  22188. * Create a new geometry from persisted data (Using .babylon file format)
  22189. * @param parsedVertexData defines the persisted data
  22190. * @param scene defines the hosting scene
  22191. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22192. * @returns the new geometry object
  22193. */
  22194. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22195. }
  22196. }
  22197. declare module BABYLON {
  22198. /**
  22199. * Define an interface for all classes that will get and set the data on vertices
  22200. */
  22201. export interface IGetSetVerticesData {
  22202. /**
  22203. * Gets a boolean indicating if specific vertex data is present
  22204. * @param kind defines the vertex data kind to use
  22205. * @returns true is data kind is present
  22206. */
  22207. isVerticesDataPresent(kind: string): boolean;
  22208. /**
  22209. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22210. * @param kind defines the data kind (Position, normal, etc...)
  22211. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22212. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22213. * @returns a float array containing vertex data
  22214. */
  22215. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22216. /**
  22217. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22218. * @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.
  22219. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22220. * @returns the indices array or an empty array if the mesh has no geometry
  22221. */
  22222. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22223. /**
  22224. * Set specific vertex data
  22225. * @param kind defines the data kind (Position, normal, etc...)
  22226. * @param data defines the vertex data to use
  22227. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22228. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22229. */
  22230. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22231. /**
  22232. * Update a specific associated vertex buffer
  22233. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22234. * - VertexBuffer.PositionKind
  22235. * - VertexBuffer.UVKind
  22236. * - VertexBuffer.UV2Kind
  22237. * - VertexBuffer.UV3Kind
  22238. * - VertexBuffer.UV4Kind
  22239. * - VertexBuffer.UV5Kind
  22240. * - VertexBuffer.UV6Kind
  22241. * - VertexBuffer.ColorKind
  22242. * - VertexBuffer.MatricesIndicesKind
  22243. * - VertexBuffer.MatricesIndicesExtraKind
  22244. * - VertexBuffer.MatricesWeightsKind
  22245. * - VertexBuffer.MatricesWeightsExtraKind
  22246. * @param data defines the data source
  22247. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22248. * @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)
  22249. */
  22250. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22251. /**
  22252. * Creates a new index buffer
  22253. * @param indices defines the indices to store in the index buffer
  22254. * @param totalVertices defines the total number of vertices (could be null)
  22255. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22256. */
  22257. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22258. }
  22259. /**
  22260. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22261. */
  22262. export class VertexData {
  22263. /**
  22264. * Mesh side orientation : usually the external or front surface
  22265. */
  22266. static readonly FRONTSIDE: number;
  22267. /**
  22268. * Mesh side orientation : usually the internal or back surface
  22269. */
  22270. static readonly BACKSIDE: number;
  22271. /**
  22272. * Mesh side orientation : both internal and external or front and back surfaces
  22273. */
  22274. static readonly DOUBLESIDE: number;
  22275. /**
  22276. * Mesh side orientation : by default, `FRONTSIDE`
  22277. */
  22278. static readonly DEFAULTSIDE: number;
  22279. /**
  22280. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22281. */
  22282. positions: Nullable<FloatArray>;
  22283. /**
  22284. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22285. */
  22286. normals: Nullable<FloatArray>;
  22287. /**
  22288. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22289. */
  22290. tangents: Nullable<FloatArray>;
  22291. /**
  22292. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22293. */
  22294. uvs: Nullable<FloatArray>;
  22295. /**
  22296. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22297. */
  22298. uvs2: Nullable<FloatArray>;
  22299. /**
  22300. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22301. */
  22302. uvs3: Nullable<FloatArray>;
  22303. /**
  22304. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22305. */
  22306. uvs4: Nullable<FloatArray>;
  22307. /**
  22308. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22309. */
  22310. uvs5: Nullable<FloatArray>;
  22311. /**
  22312. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22313. */
  22314. uvs6: Nullable<FloatArray>;
  22315. /**
  22316. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22317. */
  22318. colors: Nullable<FloatArray>;
  22319. /**
  22320. * 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).
  22321. */
  22322. matricesIndices: Nullable<FloatArray>;
  22323. /**
  22324. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22325. */
  22326. matricesWeights: Nullable<FloatArray>;
  22327. /**
  22328. * An array extending the number of possible indices
  22329. */
  22330. matricesIndicesExtra: Nullable<FloatArray>;
  22331. /**
  22332. * An array extending the number of possible weights when the number of indices is extended
  22333. */
  22334. matricesWeightsExtra: Nullable<FloatArray>;
  22335. /**
  22336. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22337. */
  22338. indices: Nullable<IndicesArray>;
  22339. /**
  22340. * Uses the passed data array to set the set the values for the specified kind of data
  22341. * @param data a linear array of floating numbers
  22342. * @param kind the type of data that is being set, eg positions, colors etc
  22343. */
  22344. set(data: FloatArray, kind: string): void;
  22345. /**
  22346. * Associates the vertexData to the passed Mesh.
  22347. * Sets it as updatable or not (default `false`)
  22348. * @param mesh the mesh the vertexData is applied to
  22349. * @param updatable when used and having the value true allows new data to update the vertexData
  22350. * @returns the VertexData
  22351. */
  22352. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22353. /**
  22354. * Associates the vertexData to the passed Geometry.
  22355. * Sets it as updatable or not (default `false`)
  22356. * @param geometry the geometry the vertexData is applied to
  22357. * @param updatable when used and having the value true allows new data to update the vertexData
  22358. * @returns VertexData
  22359. */
  22360. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22361. /**
  22362. * Updates the associated mesh
  22363. * @param mesh the mesh to be updated
  22364. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22365. * @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
  22366. * @returns VertexData
  22367. */
  22368. updateMesh(mesh: Mesh): VertexData;
  22369. /**
  22370. * Updates the associated geometry
  22371. * @param geometry the geometry to be updated
  22372. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22373. * @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
  22374. * @returns VertexData.
  22375. */
  22376. updateGeometry(geometry: Geometry): VertexData;
  22377. private _applyTo;
  22378. private _update;
  22379. /**
  22380. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22381. * @param matrix the transforming matrix
  22382. * @returns the VertexData
  22383. */
  22384. transform(matrix: Matrix): VertexData;
  22385. /**
  22386. * Merges the passed VertexData into the current one
  22387. * @param other the VertexData to be merged into the current one
  22388. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22389. * @returns the modified VertexData
  22390. */
  22391. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22392. private _mergeElement;
  22393. private _validate;
  22394. /**
  22395. * Serializes the VertexData
  22396. * @returns a serialized object
  22397. */
  22398. serialize(): any;
  22399. /**
  22400. * Extracts the vertexData from a mesh
  22401. * @param mesh the mesh from which to extract the VertexData
  22402. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22403. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22404. * @returns the object VertexData associated to the passed mesh
  22405. */
  22406. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22407. /**
  22408. * Extracts the vertexData from the geometry
  22409. * @param geometry the geometry from which to extract the VertexData
  22410. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22411. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22412. * @returns the object VertexData associated to the passed mesh
  22413. */
  22414. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22415. private static _ExtractFrom;
  22416. /**
  22417. * Creates the VertexData for a Ribbon
  22418. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22419. * * pathArray array of paths, each of which an array of successive Vector3
  22420. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22421. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22422. * * 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
  22423. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22424. * * 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)
  22425. * * 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)
  22426. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22427. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22428. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22429. * @returns the VertexData of the ribbon
  22430. */
  22431. static CreateRibbon(options: {
  22432. pathArray: Vector3[][];
  22433. closeArray?: boolean;
  22434. closePath?: boolean;
  22435. offset?: number;
  22436. sideOrientation?: number;
  22437. frontUVs?: Vector4;
  22438. backUVs?: Vector4;
  22439. invertUV?: boolean;
  22440. uvs?: Vector2[];
  22441. colors?: Color4[];
  22442. }): VertexData;
  22443. /**
  22444. * Creates the VertexData for a box
  22445. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22446. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22447. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22448. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22449. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22450. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22451. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22453. * * 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)
  22454. * * 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)
  22455. * @returns the VertexData of the box
  22456. */
  22457. static CreateBox(options: {
  22458. size?: number;
  22459. width?: number;
  22460. height?: number;
  22461. depth?: number;
  22462. faceUV?: Vector4[];
  22463. faceColors?: Color4[];
  22464. sideOrientation?: number;
  22465. frontUVs?: Vector4;
  22466. backUVs?: Vector4;
  22467. }): VertexData;
  22468. /**
  22469. * Creates the VertexData for a tiled box
  22470. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22471. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22472. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22473. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22475. * @returns the VertexData of the box
  22476. */
  22477. static CreateTiledBox(options: {
  22478. pattern?: number;
  22479. width?: number;
  22480. height?: number;
  22481. depth?: number;
  22482. tileSize?: number;
  22483. tileWidth?: number;
  22484. tileHeight?: number;
  22485. alignHorizontal?: number;
  22486. alignVertical?: number;
  22487. faceUV?: Vector4[];
  22488. faceColors?: Color4[];
  22489. sideOrientation?: number;
  22490. }): VertexData;
  22491. /**
  22492. * Creates the VertexData for a tiled plane
  22493. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22494. * * pattern a limited pattern arrangement depending on the number
  22495. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22496. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22497. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22499. * * 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)
  22500. * * 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)
  22501. * @returns the VertexData of the tiled plane
  22502. */
  22503. static CreateTiledPlane(options: {
  22504. pattern?: number;
  22505. tileSize?: number;
  22506. tileWidth?: number;
  22507. tileHeight?: number;
  22508. size?: number;
  22509. width?: number;
  22510. height?: number;
  22511. alignHorizontal?: number;
  22512. alignVertical?: number;
  22513. sideOrientation?: number;
  22514. frontUVs?: Vector4;
  22515. backUVs?: Vector4;
  22516. }): VertexData;
  22517. /**
  22518. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22519. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22520. * * segments sets the number of horizontal strips optional, default 32
  22521. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22522. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22523. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22524. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22525. * * 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
  22526. * * 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
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the ellipsoid
  22531. */
  22532. static CreateSphere(options: {
  22533. segments?: number;
  22534. diameter?: number;
  22535. diameterX?: number;
  22536. diameterY?: number;
  22537. diameterZ?: number;
  22538. arc?: number;
  22539. slice?: number;
  22540. sideOrientation?: number;
  22541. frontUVs?: Vector4;
  22542. backUVs?: Vector4;
  22543. }): VertexData;
  22544. /**
  22545. * Creates the VertexData for a cylinder, cone or prism
  22546. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22547. * * height sets the height (y direction) of the cylinder, optional, default 2
  22548. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22549. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22550. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22551. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22552. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22553. * * 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
  22554. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22555. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22556. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22557. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22559. * * 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)
  22560. * * 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)
  22561. * @returns the VertexData of the cylinder, cone or prism
  22562. */
  22563. static CreateCylinder(options: {
  22564. height?: number;
  22565. diameterTop?: number;
  22566. diameterBottom?: number;
  22567. diameter?: number;
  22568. tessellation?: number;
  22569. subdivisions?: number;
  22570. arc?: number;
  22571. faceColors?: Color4[];
  22572. faceUV?: Vector4[];
  22573. hasRings?: boolean;
  22574. enclose?: boolean;
  22575. sideOrientation?: number;
  22576. frontUVs?: Vector4;
  22577. backUVs?: Vector4;
  22578. }): VertexData;
  22579. /**
  22580. * Creates the VertexData for a torus
  22581. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22582. * * diameter the diameter of the torus, optional default 1
  22583. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22584. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22586. * * 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)
  22587. * * 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)
  22588. * @returns the VertexData of the torus
  22589. */
  22590. static CreateTorus(options: {
  22591. diameter?: number;
  22592. thickness?: number;
  22593. tessellation?: number;
  22594. sideOrientation?: number;
  22595. frontUVs?: Vector4;
  22596. backUVs?: Vector4;
  22597. }): VertexData;
  22598. /**
  22599. * Creates the VertexData of the LineSystem
  22600. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22601. * - lines an array of lines, each line being an array of successive Vector3
  22602. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22603. * @returns the VertexData of the LineSystem
  22604. */
  22605. static CreateLineSystem(options: {
  22606. lines: Vector3[][];
  22607. colors?: Nullable<Color4[][]>;
  22608. }): VertexData;
  22609. /**
  22610. * Create the VertexData for a DashedLines
  22611. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22612. * - points an array successive Vector3
  22613. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22614. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22615. * - dashNb the intended total number of dashes, optional, default 200
  22616. * @returns the VertexData for the DashedLines
  22617. */
  22618. static CreateDashedLines(options: {
  22619. points: Vector3[];
  22620. dashSize?: number;
  22621. gapSize?: number;
  22622. dashNb?: number;
  22623. }): VertexData;
  22624. /**
  22625. * Creates the VertexData for a Ground
  22626. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22627. * - width the width (x direction) of the ground, optional, default 1
  22628. * - height the height (z direction) of the ground, optional, default 1
  22629. * - subdivisions the number of subdivisions per side, optional, default 1
  22630. * @returns the VertexData of the Ground
  22631. */
  22632. static CreateGround(options: {
  22633. width?: number;
  22634. height?: number;
  22635. subdivisions?: number;
  22636. subdivisionsX?: number;
  22637. subdivisionsY?: number;
  22638. }): VertexData;
  22639. /**
  22640. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22641. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22642. * * xmin the ground minimum X coordinate, optional, default -1
  22643. * * zmin the ground minimum Z coordinate, optional, default -1
  22644. * * xmax the ground maximum X coordinate, optional, default 1
  22645. * * zmax the ground maximum Z coordinate, optional, default 1
  22646. * * 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}
  22647. * * 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}
  22648. * @returns the VertexData of the TiledGround
  22649. */
  22650. static CreateTiledGround(options: {
  22651. xmin: number;
  22652. zmin: number;
  22653. xmax: number;
  22654. zmax: number;
  22655. subdivisions?: {
  22656. w: number;
  22657. h: number;
  22658. };
  22659. precision?: {
  22660. w: number;
  22661. h: number;
  22662. };
  22663. }): VertexData;
  22664. /**
  22665. * Creates the VertexData of the Ground designed from a heightmap
  22666. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22667. * * width the width (x direction) of the ground
  22668. * * height the height (z direction) of the ground
  22669. * * subdivisions the number of subdivisions per side
  22670. * * minHeight the minimum altitude on the ground, optional, default 0
  22671. * * maxHeight the maximum altitude on the ground, optional default 1
  22672. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22673. * * buffer the array holding the image color data
  22674. * * bufferWidth the width of image
  22675. * * bufferHeight the height of image
  22676. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22677. * @returns the VertexData of the Ground designed from a heightmap
  22678. */
  22679. static CreateGroundFromHeightMap(options: {
  22680. width: number;
  22681. height: number;
  22682. subdivisions: number;
  22683. minHeight: number;
  22684. maxHeight: number;
  22685. colorFilter: Color3;
  22686. buffer: Uint8Array;
  22687. bufferWidth: number;
  22688. bufferHeight: number;
  22689. alphaFilter: number;
  22690. }): VertexData;
  22691. /**
  22692. * Creates the VertexData for a Plane
  22693. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22694. * * size sets the width and height of the plane to the value of size, optional default 1
  22695. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22696. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22698. * * 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)
  22699. * * 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)
  22700. * @returns the VertexData of the box
  22701. */
  22702. static CreatePlane(options: {
  22703. size?: number;
  22704. width?: number;
  22705. height?: number;
  22706. sideOrientation?: number;
  22707. frontUVs?: Vector4;
  22708. backUVs?: Vector4;
  22709. }): VertexData;
  22710. /**
  22711. * Creates the VertexData of the Disc or regular Polygon
  22712. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22713. * * radius the radius of the disc, optional default 0.5
  22714. * * tessellation the number of polygon sides, optional, default 64
  22715. * * 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
  22716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22717. * * 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)
  22718. * * 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)
  22719. * @returns the VertexData of the box
  22720. */
  22721. static CreateDisc(options: {
  22722. radius?: number;
  22723. tessellation?: number;
  22724. arc?: number;
  22725. sideOrientation?: number;
  22726. frontUVs?: Vector4;
  22727. backUVs?: Vector4;
  22728. }): VertexData;
  22729. /**
  22730. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22731. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22732. * @param polygon a mesh built from polygonTriangulation.build()
  22733. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22734. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22735. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22736. * @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)
  22737. * @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)
  22738. * @returns the VertexData of the Polygon
  22739. */
  22740. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22741. /**
  22742. * Creates the VertexData of the IcoSphere
  22743. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22744. * * radius the radius of the IcoSphere, optional default 1
  22745. * * radiusX allows stretching in the x direction, optional, default radius
  22746. * * radiusY allows stretching in the y direction, optional, default radius
  22747. * * radiusZ allows stretching in the z direction, optional, default radius
  22748. * * flat when true creates a flat shaded mesh, optional, default true
  22749. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22751. * * 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)
  22752. * * 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)
  22753. * @returns the VertexData of the IcoSphere
  22754. */
  22755. static CreateIcoSphere(options: {
  22756. radius?: number;
  22757. radiusX?: number;
  22758. radiusY?: number;
  22759. radiusZ?: number;
  22760. flat?: boolean;
  22761. subdivisions?: number;
  22762. sideOrientation?: number;
  22763. frontUVs?: Vector4;
  22764. backUVs?: Vector4;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for a Polyhedron
  22768. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22769. * * type provided types are:
  22770. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22771. * * 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)
  22772. * * size the size of the IcoSphere, optional default 1
  22773. * * sizeX allows stretching in the x direction, optional, default size
  22774. * * sizeY allows stretching in the y direction, optional, default size
  22775. * * sizeZ allows stretching in the z direction, optional, default size
  22776. * * 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
  22777. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22778. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22779. * * flat when true creates a flat shaded mesh, optional, default true
  22780. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22782. * * 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)
  22783. * * 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)
  22784. * @returns the VertexData of the Polyhedron
  22785. */
  22786. static CreatePolyhedron(options: {
  22787. type?: number;
  22788. size?: number;
  22789. sizeX?: number;
  22790. sizeY?: number;
  22791. sizeZ?: number;
  22792. custom?: any;
  22793. faceUV?: Vector4[];
  22794. faceColors?: Color4[];
  22795. flat?: boolean;
  22796. sideOrientation?: number;
  22797. frontUVs?: Vector4;
  22798. backUVs?: Vector4;
  22799. }): VertexData;
  22800. /**
  22801. * Creates the VertexData for a TorusKnot
  22802. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22803. * * radius the radius of the torus knot, optional, default 2
  22804. * * tube the thickness of the tube, optional, default 0.5
  22805. * * radialSegments the number of sides on each tube segments, optional, default 32
  22806. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22807. * * p the number of windings around the z axis, optional, default 2
  22808. * * q the number of windings around the x axis, optional, default 3
  22809. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22810. * * 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)
  22811. * * 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)
  22812. * @returns the VertexData of the Torus Knot
  22813. */
  22814. static CreateTorusKnot(options: {
  22815. radius?: number;
  22816. tube?: number;
  22817. radialSegments?: number;
  22818. tubularSegments?: number;
  22819. p?: number;
  22820. q?: number;
  22821. sideOrientation?: number;
  22822. frontUVs?: Vector4;
  22823. backUVs?: Vector4;
  22824. }): VertexData;
  22825. /**
  22826. * Compute normals for given positions and indices
  22827. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22828. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22829. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22830. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22831. * * facetNormals : optional array of facet normals (vector3)
  22832. * * facetPositions : optional array of facet positions (vector3)
  22833. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22834. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22835. * * bInfo : optional bounding info, required for facetPartitioning computation
  22836. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22837. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22838. * * useRightHandedSystem: optional boolean to for right handed system computation
  22839. * * depthSort : optional boolean to enable the facet depth sort computation
  22840. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22841. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22842. */
  22843. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22844. facetNormals?: any;
  22845. facetPositions?: any;
  22846. facetPartitioning?: any;
  22847. ratio?: number;
  22848. bInfo?: any;
  22849. bbSize?: Vector3;
  22850. subDiv?: any;
  22851. useRightHandedSystem?: boolean;
  22852. depthSort?: boolean;
  22853. distanceTo?: Vector3;
  22854. depthSortedFacets?: any;
  22855. }): void;
  22856. /** @hidden */
  22857. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22858. /**
  22859. * Applies VertexData created from the imported parameters to the geometry
  22860. * @param parsedVertexData the parsed data from an imported file
  22861. * @param geometry the geometry to apply the VertexData to
  22862. */
  22863. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22864. }
  22865. }
  22866. declare module BABYLON {
  22867. /**
  22868. * Defines a target to use with MorphTargetManager
  22869. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22870. */
  22871. export class MorphTarget implements IAnimatable {
  22872. /** defines the name of the target */
  22873. name: string;
  22874. /**
  22875. * Gets or sets the list of animations
  22876. */
  22877. animations: Animation[];
  22878. private _scene;
  22879. private _positions;
  22880. private _normals;
  22881. private _tangents;
  22882. private _uvs;
  22883. private _influence;
  22884. private _uniqueId;
  22885. /**
  22886. * Observable raised when the influence changes
  22887. */
  22888. onInfluenceChanged: Observable<boolean>;
  22889. /** @hidden */
  22890. _onDataLayoutChanged: Observable<void>;
  22891. /**
  22892. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22893. */
  22894. get influence(): number;
  22895. set influence(influence: number);
  22896. /**
  22897. * Gets or sets the id of the morph Target
  22898. */
  22899. id: string;
  22900. private _animationPropertiesOverride;
  22901. /**
  22902. * Gets or sets the animation properties override
  22903. */
  22904. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22905. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22906. /**
  22907. * Creates a new MorphTarget
  22908. * @param name defines the name of the target
  22909. * @param influence defines the influence to use
  22910. * @param scene defines the scene the morphtarget belongs to
  22911. */
  22912. constructor(
  22913. /** defines the name of the target */
  22914. name: string, influence?: number, scene?: Nullable<Scene>);
  22915. /**
  22916. * Gets the unique ID of this manager
  22917. */
  22918. get uniqueId(): number;
  22919. /**
  22920. * Gets a boolean defining if the target contains position data
  22921. */
  22922. get hasPositions(): boolean;
  22923. /**
  22924. * Gets a boolean defining if the target contains normal data
  22925. */
  22926. get hasNormals(): boolean;
  22927. /**
  22928. * Gets a boolean defining if the target contains tangent data
  22929. */
  22930. get hasTangents(): boolean;
  22931. /**
  22932. * Gets a boolean defining if the target contains texture coordinates data
  22933. */
  22934. get hasUVs(): boolean;
  22935. /**
  22936. * Affects position data to this target
  22937. * @param data defines the position data to use
  22938. */
  22939. setPositions(data: Nullable<FloatArray>): void;
  22940. /**
  22941. * Gets the position data stored in this target
  22942. * @returns a FloatArray containing the position data (or null if not present)
  22943. */
  22944. getPositions(): Nullable<FloatArray>;
  22945. /**
  22946. * Affects normal data to this target
  22947. * @param data defines the normal data to use
  22948. */
  22949. setNormals(data: Nullable<FloatArray>): void;
  22950. /**
  22951. * Gets the normal data stored in this target
  22952. * @returns a FloatArray containing the normal data (or null if not present)
  22953. */
  22954. getNormals(): Nullable<FloatArray>;
  22955. /**
  22956. * Affects tangent data to this target
  22957. * @param data defines the tangent data to use
  22958. */
  22959. setTangents(data: Nullable<FloatArray>): void;
  22960. /**
  22961. * Gets the tangent data stored in this target
  22962. * @returns a FloatArray containing the tangent data (or null if not present)
  22963. */
  22964. getTangents(): Nullable<FloatArray>;
  22965. /**
  22966. * Affects texture coordinates data to this target
  22967. * @param data defines the texture coordinates data to use
  22968. */
  22969. setUVs(data: Nullable<FloatArray>): void;
  22970. /**
  22971. * Gets the texture coordinates data stored in this target
  22972. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22973. */
  22974. getUVs(): Nullable<FloatArray>;
  22975. /**
  22976. * Clone the current target
  22977. * @returns a new MorphTarget
  22978. */
  22979. clone(): MorphTarget;
  22980. /**
  22981. * Serializes the current target into a Serialization object
  22982. * @returns the serialized object
  22983. */
  22984. serialize(): any;
  22985. /**
  22986. * Returns the string "MorphTarget"
  22987. * @returns "MorphTarget"
  22988. */
  22989. getClassName(): string;
  22990. /**
  22991. * Creates a new target from serialized data
  22992. * @param serializationObject defines the serialized data to use
  22993. * @returns a new MorphTarget
  22994. */
  22995. static Parse(serializationObject: any): MorphTarget;
  22996. /**
  22997. * Creates a MorphTarget from mesh data
  22998. * @param mesh defines the source mesh
  22999. * @param name defines the name to use for the new target
  23000. * @param influence defines the influence to attach to the target
  23001. * @returns a new MorphTarget
  23002. */
  23003. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23004. }
  23005. }
  23006. declare module BABYLON {
  23007. /**
  23008. * This class is used to deform meshes using morphing between different targets
  23009. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23010. */
  23011. export class MorphTargetManager {
  23012. private _targets;
  23013. private _targetInfluenceChangedObservers;
  23014. private _targetDataLayoutChangedObservers;
  23015. private _activeTargets;
  23016. private _scene;
  23017. private _influences;
  23018. private _supportsNormals;
  23019. private _supportsTangents;
  23020. private _supportsUVs;
  23021. private _vertexCount;
  23022. private _uniqueId;
  23023. private _tempInfluences;
  23024. /**
  23025. * Gets or sets a boolean indicating if normals must be morphed
  23026. */
  23027. enableNormalMorphing: boolean;
  23028. /**
  23029. * Gets or sets a boolean indicating if tangents must be morphed
  23030. */
  23031. enableTangentMorphing: boolean;
  23032. /**
  23033. * Gets or sets a boolean indicating if UV must be morphed
  23034. */
  23035. enableUVMorphing: boolean;
  23036. /**
  23037. * Creates a new MorphTargetManager
  23038. * @param scene defines the current scene
  23039. */
  23040. constructor(scene?: Nullable<Scene>);
  23041. /**
  23042. * Gets the unique ID of this manager
  23043. */
  23044. get uniqueId(): number;
  23045. /**
  23046. * Gets the number of vertices handled by this manager
  23047. */
  23048. get vertexCount(): number;
  23049. /**
  23050. * Gets a boolean indicating if this manager supports morphing of normals
  23051. */
  23052. get supportsNormals(): boolean;
  23053. /**
  23054. * Gets a boolean indicating if this manager supports morphing of tangents
  23055. */
  23056. get supportsTangents(): boolean;
  23057. /**
  23058. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23059. */
  23060. get supportsUVs(): boolean;
  23061. /**
  23062. * Gets the number of targets stored in this manager
  23063. */
  23064. get numTargets(): number;
  23065. /**
  23066. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23067. */
  23068. get numInfluencers(): number;
  23069. /**
  23070. * Gets the list of influences (one per target)
  23071. */
  23072. get influences(): Float32Array;
  23073. /**
  23074. * Gets the active target at specified index. An active target is a target with an influence > 0
  23075. * @param index defines the index to check
  23076. * @returns the requested target
  23077. */
  23078. getActiveTarget(index: number): MorphTarget;
  23079. /**
  23080. * Gets the target at specified index
  23081. * @param index defines the index to check
  23082. * @returns the requested target
  23083. */
  23084. getTarget(index: number): MorphTarget;
  23085. /**
  23086. * Add a new target to this manager
  23087. * @param target defines the target to add
  23088. */
  23089. addTarget(target: MorphTarget): void;
  23090. /**
  23091. * Removes a target from the manager
  23092. * @param target defines the target to remove
  23093. */
  23094. removeTarget(target: MorphTarget): void;
  23095. /**
  23096. * Clone the current manager
  23097. * @returns a new MorphTargetManager
  23098. */
  23099. clone(): MorphTargetManager;
  23100. /**
  23101. * Serializes the current manager into a Serialization object
  23102. * @returns the serialized object
  23103. */
  23104. serialize(): any;
  23105. private _syncActiveTargets;
  23106. /**
  23107. * Syncrhonize the targets with all the meshes using this morph target manager
  23108. */
  23109. synchronize(): void;
  23110. /**
  23111. * Creates a new MorphTargetManager from serialized data
  23112. * @param serializationObject defines the serialized data
  23113. * @param scene defines the hosting scene
  23114. * @returns the new MorphTargetManager
  23115. */
  23116. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23117. }
  23118. }
  23119. declare module BABYLON {
  23120. /**
  23121. * Class used to represent a specific level of detail of a mesh
  23122. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23123. */
  23124. export class MeshLODLevel {
  23125. /** Defines the distance where this level should start being displayed */
  23126. distance: number;
  23127. /** Defines the mesh to use to render this level */
  23128. mesh: Nullable<Mesh>;
  23129. /**
  23130. * Creates a new LOD level
  23131. * @param distance defines the distance where this level should star being displayed
  23132. * @param mesh defines the mesh to use to render this level
  23133. */
  23134. constructor(
  23135. /** Defines the distance where this level should start being displayed */
  23136. distance: number,
  23137. /** Defines the mesh to use to render this level */
  23138. mesh: Nullable<Mesh>);
  23139. }
  23140. }
  23141. declare module BABYLON {
  23142. /**
  23143. * Mesh representing the gorund
  23144. */
  23145. export class GroundMesh extends Mesh {
  23146. /** If octree should be generated */
  23147. generateOctree: boolean;
  23148. private _heightQuads;
  23149. /** @hidden */
  23150. _subdivisionsX: number;
  23151. /** @hidden */
  23152. _subdivisionsY: number;
  23153. /** @hidden */
  23154. _width: number;
  23155. /** @hidden */
  23156. _height: number;
  23157. /** @hidden */
  23158. _minX: number;
  23159. /** @hidden */
  23160. _maxX: number;
  23161. /** @hidden */
  23162. _minZ: number;
  23163. /** @hidden */
  23164. _maxZ: number;
  23165. constructor(name: string, scene: Scene);
  23166. /**
  23167. * "GroundMesh"
  23168. * @returns "GroundMesh"
  23169. */
  23170. getClassName(): string;
  23171. /**
  23172. * The minimum of x and y subdivisions
  23173. */
  23174. get subdivisions(): number;
  23175. /**
  23176. * X subdivisions
  23177. */
  23178. get subdivisionsX(): number;
  23179. /**
  23180. * Y subdivisions
  23181. */
  23182. get subdivisionsY(): number;
  23183. /**
  23184. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23185. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23186. * @param chunksCount the number of subdivisions for x and y
  23187. * @param octreeBlocksSize (Default: 32)
  23188. */
  23189. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23190. /**
  23191. * Returns a height (y) value in the Worl system :
  23192. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23193. * @param x x coordinate
  23194. * @param z z coordinate
  23195. * @returns the ground y position if (x, z) are outside the ground surface.
  23196. */
  23197. getHeightAtCoordinates(x: number, z: number): number;
  23198. /**
  23199. * Returns a normalized vector (Vector3) orthogonal to the ground
  23200. * at the ground coordinates (x, z) expressed in the World system.
  23201. * @param x x coordinate
  23202. * @param z z coordinate
  23203. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23204. */
  23205. getNormalAtCoordinates(x: number, z: number): Vector3;
  23206. /**
  23207. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23208. * at the ground coordinates (x, z) expressed in the World system.
  23209. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23210. * @param x x coordinate
  23211. * @param z z coordinate
  23212. * @param ref vector to store the result
  23213. * @returns the GroundMesh.
  23214. */
  23215. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23216. /**
  23217. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23218. * if the ground has been updated.
  23219. * This can be used in the render loop.
  23220. * @returns the GroundMesh.
  23221. */
  23222. updateCoordinateHeights(): GroundMesh;
  23223. private _getFacetAt;
  23224. private _initHeightQuads;
  23225. private _computeHeightQuads;
  23226. /**
  23227. * Serializes this ground mesh
  23228. * @param serializationObject object to write serialization to
  23229. */
  23230. serialize(serializationObject: any): void;
  23231. /**
  23232. * Parses a serialized ground mesh
  23233. * @param parsedMesh the serialized mesh
  23234. * @param scene the scene to create the ground mesh in
  23235. * @returns the created ground mesh
  23236. */
  23237. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23238. }
  23239. }
  23240. declare module BABYLON {
  23241. /**
  23242. * Interface for Physics-Joint data
  23243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23244. */
  23245. export interface PhysicsJointData {
  23246. /**
  23247. * The main pivot of the joint
  23248. */
  23249. mainPivot?: Vector3;
  23250. /**
  23251. * The connected pivot of the joint
  23252. */
  23253. connectedPivot?: Vector3;
  23254. /**
  23255. * The main axis of the joint
  23256. */
  23257. mainAxis?: Vector3;
  23258. /**
  23259. * The connected axis of the joint
  23260. */
  23261. connectedAxis?: Vector3;
  23262. /**
  23263. * The collision of the joint
  23264. */
  23265. collision?: boolean;
  23266. /**
  23267. * Native Oimo/Cannon/Energy data
  23268. */
  23269. nativeParams?: any;
  23270. }
  23271. /**
  23272. * This is a holder class for the physics joint created by the physics plugin
  23273. * It holds a set of functions to control the underlying joint
  23274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23275. */
  23276. export class PhysicsJoint {
  23277. /**
  23278. * The type of the physics joint
  23279. */
  23280. type: number;
  23281. /**
  23282. * The data for the physics joint
  23283. */
  23284. jointData: PhysicsJointData;
  23285. private _physicsJoint;
  23286. protected _physicsPlugin: IPhysicsEnginePlugin;
  23287. /**
  23288. * Initializes the physics joint
  23289. * @param type The type of the physics joint
  23290. * @param jointData The data for the physics joint
  23291. */
  23292. constructor(
  23293. /**
  23294. * The type of the physics joint
  23295. */
  23296. type: number,
  23297. /**
  23298. * The data for the physics joint
  23299. */
  23300. jointData: PhysicsJointData);
  23301. /**
  23302. * Gets the physics joint
  23303. */
  23304. get physicsJoint(): any;
  23305. /**
  23306. * Sets the physics joint
  23307. */
  23308. set physicsJoint(newJoint: any);
  23309. /**
  23310. * Sets the physics plugin
  23311. */
  23312. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23313. /**
  23314. * Execute a function that is physics-plugin specific.
  23315. * @param {Function} func the function that will be executed.
  23316. * It accepts two parameters: the physics world and the physics joint
  23317. */
  23318. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23319. /**
  23320. * Distance-Joint type
  23321. */
  23322. static DistanceJoint: number;
  23323. /**
  23324. * Hinge-Joint type
  23325. */
  23326. static HingeJoint: number;
  23327. /**
  23328. * Ball-and-Socket joint type
  23329. */
  23330. static BallAndSocketJoint: number;
  23331. /**
  23332. * Wheel-Joint type
  23333. */
  23334. static WheelJoint: number;
  23335. /**
  23336. * Slider-Joint type
  23337. */
  23338. static SliderJoint: number;
  23339. /**
  23340. * Prismatic-Joint type
  23341. */
  23342. static PrismaticJoint: number;
  23343. /**
  23344. * Universal-Joint type
  23345. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23346. */
  23347. static UniversalJoint: number;
  23348. /**
  23349. * Hinge-Joint 2 type
  23350. */
  23351. static Hinge2Joint: number;
  23352. /**
  23353. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23354. */
  23355. static PointToPointJoint: number;
  23356. /**
  23357. * Spring-Joint type
  23358. */
  23359. static SpringJoint: number;
  23360. /**
  23361. * Lock-Joint type
  23362. */
  23363. static LockJoint: number;
  23364. }
  23365. /**
  23366. * A class representing a physics distance joint
  23367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23368. */
  23369. export class DistanceJoint extends PhysicsJoint {
  23370. /**
  23371. *
  23372. * @param jointData The data for the Distance-Joint
  23373. */
  23374. constructor(jointData: DistanceJointData);
  23375. /**
  23376. * Update the predefined distance.
  23377. * @param maxDistance The maximum preferred distance
  23378. * @param minDistance The minimum preferred distance
  23379. */
  23380. updateDistance(maxDistance: number, minDistance?: number): void;
  23381. }
  23382. /**
  23383. * Represents a Motor-Enabled Joint
  23384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23385. */
  23386. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23387. /**
  23388. * Initializes the Motor-Enabled Joint
  23389. * @param type The type of the joint
  23390. * @param jointData The physica joint data for the joint
  23391. */
  23392. constructor(type: number, jointData: PhysicsJointData);
  23393. /**
  23394. * Set the motor values.
  23395. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23396. * @param force the force to apply
  23397. * @param maxForce max force for this motor.
  23398. */
  23399. setMotor(force?: number, maxForce?: number): void;
  23400. /**
  23401. * Set the motor's limits.
  23402. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23403. * @param upperLimit The upper limit of the motor
  23404. * @param lowerLimit The lower limit of the motor
  23405. */
  23406. setLimit(upperLimit: number, lowerLimit?: number): void;
  23407. }
  23408. /**
  23409. * This class represents a single physics Hinge-Joint
  23410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23411. */
  23412. export class HingeJoint extends MotorEnabledJoint {
  23413. /**
  23414. * Initializes the Hinge-Joint
  23415. * @param jointData The joint data for the Hinge-Joint
  23416. */
  23417. constructor(jointData: PhysicsJointData);
  23418. /**
  23419. * Set the motor values.
  23420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23421. * @param {number} force the force to apply
  23422. * @param {number} maxForce max force for this motor.
  23423. */
  23424. setMotor(force?: number, maxForce?: number): void;
  23425. /**
  23426. * Set the motor's limits.
  23427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23428. * @param upperLimit The upper limit of the motor
  23429. * @param lowerLimit The lower limit of the motor
  23430. */
  23431. setLimit(upperLimit: number, lowerLimit?: number): void;
  23432. }
  23433. /**
  23434. * This class represents a dual hinge physics joint (same as wheel joint)
  23435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23436. */
  23437. export class Hinge2Joint extends MotorEnabledJoint {
  23438. /**
  23439. * Initializes the Hinge2-Joint
  23440. * @param jointData The joint data for the Hinge2-Joint
  23441. */
  23442. constructor(jointData: PhysicsJointData);
  23443. /**
  23444. * Set the motor values.
  23445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23446. * @param {number} targetSpeed the speed the motor is to reach
  23447. * @param {number} maxForce max force for this motor.
  23448. * @param {motorIndex} the motor's index, 0 or 1.
  23449. */
  23450. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23451. /**
  23452. * Set the motor limits.
  23453. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23454. * @param {number} upperLimit the upper limit
  23455. * @param {number} lowerLimit lower limit
  23456. * @param {motorIndex} the motor's index, 0 or 1.
  23457. */
  23458. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23459. }
  23460. /**
  23461. * Interface for a motor enabled joint
  23462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23463. */
  23464. export interface IMotorEnabledJoint {
  23465. /**
  23466. * Physics joint
  23467. */
  23468. physicsJoint: any;
  23469. /**
  23470. * Sets the motor of the motor-enabled joint
  23471. * @param force The force of the motor
  23472. * @param maxForce The maximum force of the motor
  23473. * @param motorIndex The index of the motor
  23474. */
  23475. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23476. /**
  23477. * Sets the limit of the motor
  23478. * @param upperLimit The upper limit of the motor
  23479. * @param lowerLimit The lower limit of the motor
  23480. * @param motorIndex The index of the motor
  23481. */
  23482. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23483. }
  23484. /**
  23485. * Joint data for a Distance-Joint
  23486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23487. */
  23488. export interface DistanceJointData extends PhysicsJointData {
  23489. /**
  23490. * Max distance the 2 joint objects can be apart
  23491. */
  23492. maxDistance: number;
  23493. }
  23494. /**
  23495. * Joint data from a spring joint
  23496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23497. */
  23498. export interface SpringJointData extends PhysicsJointData {
  23499. /**
  23500. * Length of the spring
  23501. */
  23502. length: number;
  23503. /**
  23504. * Stiffness of the spring
  23505. */
  23506. stiffness: number;
  23507. /**
  23508. * Damping of the spring
  23509. */
  23510. damping: number;
  23511. /** this callback will be called when applying the force to the impostors. */
  23512. forceApplicationCallback: () => void;
  23513. }
  23514. }
  23515. declare module BABYLON {
  23516. /**
  23517. * Holds the data for the raycast result
  23518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23519. */
  23520. export class PhysicsRaycastResult {
  23521. private _hasHit;
  23522. private _hitDistance;
  23523. private _hitNormalWorld;
  23524. private _hitPointWorld;
  23525. private _rayFromWorld;
  23526. private _rayToWorld;
  23527. /**
  23528. * Gets if there was a hit
  23529. */
  23530. get hasHit(): boolean;
  23531. /**
  23532. * Gets the distance from the hit
  23533. */
  23534. get hitDistance(): number;
  23535. /**
  23536. * Gets the hit normal/direction in the world
  23537. */
  23538. get hitNormalWorld(): Vector3;
  23539. /**
  23540. * Gets the hit point in the world
  23541. */
  23542. get hitPointWorld(): Vector3;
  23543. /**
  23544. * Gets the ray "start point" of the ray in the world
  23545. */
  23546. get rayFromWorld(): Vector3;
  23547. /**
  23548. * Gets the ray "end point" of the ray in the world
  23549. */
  23550. get rayToWorld(): Vector3;
  23551. /**
  23552. * Sets the hit data (normal & point in world space)
  23553. * @param hitNormalWorld defines the normal in world space
  23554. * @param hitPointWorld defines the point in world space
  23555. */
  23556. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23557. /**
  23558. * Sets the distance from the start point to the hit point
  23559. * @param distance
  23560. */
  23561. setHitDistance(distance: number): void;
  23562. /**
  23563. * Calculates the distance manually
  23564. */
  23565. calculateHitDistance(): void;
  23566. /**
  23567. * Resets all the values to default
  23568. * @param from The from point on world space
  23569. * @param to The to point on world space
  23570. */
  23571. reset(from?: Vector3, to?: Vector3): void;
  23572. }
  23573. /**
  23574. * Interface for the size containing width and height
  23575. */
  23576. interface IXYZ {
  23577. /**
  23578. * X
  23579. */
  23580. x: number;
  23581. /**
  23582. * Y
  23583. */
  23584. y: number;
  23585. /**
  23586. * Z
  23587. */
  23588. z: number;
  23589. }
  23590. }
  23591. declare module BABYLON {
  23592. /**
  23593. * Interface used to describe a physics joint
  23594. */
  23595. export interface PhysicsImpostorJoint {
  23596. /** Defines the main impostor to which the joint is linked */
  23597. mainImpostor: PhysicsImpostor;
  23598. /** Defines the impostor that is connected to the main impostor using this joint */
  23599. connectedImpostor: PhysicsImpostor;
  23600. /** Defines the joint itself */
  23601. joint: PhysicsJoint;
  23602. }
  23603. /** @hidden */
  23604. export interface IPhysicsEnginePlugin {
  23605. world: any;
  23606. name: string;
  23607. setGravity(gravity: Vector3): void;
  23608. setTimeStep(timeStep: number): void;
  23609. getTimeStep(): number;
  23610. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23611. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23612. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23613. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23614. removePhysicsBody(impostor: PhysicsImpostor): void;
  23615. generateJoint(joint: PhysicsImpostorJoint): void;
  23616. removeJoint(joint: PhysicsImpostorJoint): void;
  23617. isSupported(): boolean;
  23618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23619. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23621. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23622. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23623. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23625. getBodyMass(impostor: PhysicsImpostor): number;
  23626. getBodyFriction(impostor: PhysicsImpostor): number;
  23627. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23628. getBodyRestitution(impostor: PhysicsImpostor): number;
  23629. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23630. getBodyPressure?(impostor: PhysicsImpostor): number;
  23631. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23632. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23633. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23634. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23635. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23636. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23637. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23638. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23639. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23640. sleepBody(impostor: PhysicsImpostor): void;
  23641. wakeUpBody(impostor: PhysicsImpostor): void;
  23642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23644. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23646. getRadius(impostor: PhysicsImpostor): number;
  23647. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23648. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23649. dispose(): void;
  23650. }
  23651. /**
  23652. * Interface used to define a physics engine
  23653. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23654. */
  23655. export interface IPhysicsEngine {
  23656. /**
  23657. * Gets the gravity vector used by the simulation
  23658. */
  23659. gravity: Vector3;
  23660. /**
  23661. * Sets the gravity vector used by the simulation
  23662. * @param gravity defines the gravity vector to use
  23663. */
  23664. setGravity(gravity: Vector3): void;
  23665. /**
  23666. * Set the time step of the physics engine.
  23667. * Default is 1/60.
  23668. * To slow it down, enter 1/600 for example.
  23669. * To speed it up, 1/30
  23670. * @param newTimeStep the new timestep to apply to this world.
  23671. */
  23672. setTimeStep(newTimeStep: number): void;
  23673. /**
  23674. * Get the time step of the physics engine.
  23675. * @returns the current time step
  23676. */
  23677. getTimeStep(): number;
  23678. /**
  23679. * Set the sub time step of the physics engine.
  23680. * Default is 0 meaning there is no sub steps
  23681. * To increase physics resolution precision, set a small value (like 1 ms)
  23682. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23683. */
  23684. setSubTimeStep(subTimeStep: number): void;
  23685. /**
  23686. * Get the sub time step of the physics engine.
  23687. * @returns the current sub time step
  23688. */
  23689. getSubTimeStep(): number;
  23690. /**
  23691. * Release all resources
  23692. */
  23693. dispose(): void;
  23694. /**
  23695. * Gets the name of the current physics plugin
  23696. * @returns the name of the plugin
  23697. */
  23698. getPhysicsPluginName(): string;
  23699. /**
  23700. * Adding a new impostor for the impostor tracking.
  23701. * This will be done by the impostor itself.
  23702. * @param impostor the impostor to add
  23703. */
  23704. addImpostor(impostor: PhysicsImpostor): void;
  23705. /**
  23706. * Remove an impostor from the engine.
  23707. * This impostor and its mesh will not longer be updated by the physics engine.
  23708. * @param impostor the impostor to remove
  23709. */
  23710. removeImpostor(impostor: PhysicsImpostor): void;
  23711. /**
  23712. * Add a joint to the physics engine
  23713. * @param mainImpostor defines the main impostor to which the joint is added.
  23714. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23715. * @param joint defines the joint that will connect both impostors.
  23716. */
  23717. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23718. /**
  23719. * Removes a joint from the simulation
  23720. * @param mainImpostor defines the impostor used with the joint
  23721. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23722. * @param joint defines the joint to remove
  23723. */
  23724. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23725. /**
  23726. * Gets the current plugin used to run the simulation
  23727. * @returns current plugin
  23728. */
  23729. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23730. /**
  23731. * Gets the list of physic impostors
  23732. * @returns an array of PhysicsImpostor
  23733. */
  23734. getImpostors(): Array<PhysicsImpostor>;
  23735. /**
  23736. * Gets the impostor for a physics enabled object
  23737. * @param object defines the object impersonated by the impostor
  23738. * @returns the PhysicsImpostor or null if not found
  23739. */
  23740. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23741. /**
  23742. * Gets the impostor for a physics body object
  23743. * @param body defines physics body used by the impostor
  23744. * @returns the PhysicsImpostor or null if not found
  23745. */
  23746. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23747. /**
  23748. * Does a raycast in the physics world
  23749. * @param from when should the ray start?
  23750. * @param to when should the ray end?
  23751. * @returns PhysicsRaycastResult
  23752. */
  23753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23754. /**
  23755. * Called by the scene. No need to call it.
  23756. * @param delta defines the timespam between frames
  23757. */
  23758. _step(delta: number): void;
  23759. }
  23760. }
  23761. declare module BABYLON {
  23762. /**
  23763. * The interface for the physics imposter parameters
  23764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23765. */
  23766. export interface PhysicsImpostorParameters {
  23767. /**
  23768. * The mass of the physics imposter
  23769. */
  23770. mass: number;
  23771. /**
  23772. * The friction of the physics imposter
  23773. */
  23774. friction?: number;
  23775. /**
  23776. * The coefficient of restitution of the physics imposter
  23777. */
  23778. restitution?: number;
  23779. /**
  23780. * The native options of the physics imposter
  23781. */
  23782. nativeOptions?: any;
  23783. /**
  23784. * Specifies if the parent should be ignored
  23785. */
  23786. ignoreParent?: boolean;
  23787. /**
  23788. * Specifies if bi-directional transformations should be disabled
  23789. */
  23790. disableBidirectionalTransformation?: boolean;
  23791. /**
  23792. * The pressure inside the physics imposter, soft object only
  23793. */
  23794. pressure?: number;
  23795. /**
  23796. * The stiffness the physics imposter, soft object only
  23797. */
  23798. stiffness?: number;
  23799. /**
  23800. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23801. */
  23802. velocityIterations?: number;
  23803. /**
  23804. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23805. */
  23806. positionIterations?: number;
  23807. /**
  23808. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23809. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23810. * Add to fix multiple points
  23811. */
  23812. fixedPoints?: number;
  23813. /**
  23814. * The collision margin around a soft object
  23815. */
  23816. margin?: number;
  23817. /**
  23818. * The collision margin around a soft object
  23819. */
  23820. damping?: number;
  23821. /**
  23822. * The path for a rope based on an extrusion
  23823. */
  23824. path?: any;
  23825. /**
  23826. * The shape of an extrusion used for a rope based on an extrusion
  23827. */
  23828. shape?: any;
  23829. }
  23830. /**
  23831. * Interface for a physics-enabled object
  23832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23833. */
  23834. export interface IPhysicsEnabledObject {
  23835. /**
  23836. * The position of the physics-enabled object
  23837. */
  23838. position: Vector3;
  23839. /**
  23840. * The rotation of the physics-enabled object
  23841. */
  23842. rotationQuaternion: Nullable<Quaternion>;
  23843. /**
  23844. * The scale of the physics-enabled object
  23845. */
  23846. scaling: Vector3;
  23847. /**
  23848. * The rotation of the physics-enabled object
  23849. */
  23850. rotation?: Vector3;
  23851. /**
  23852. * The parent of the physics-enabled object
  23853. */
  23854. parent?: any;
  23855. /**
  23856. * The bounding info of the physics-enabled object
  23857. * @returns The bounding info of the physics-enabled object
  23858. */
  23859. getBoundingInfo(): BoundingInfo;
  23860. /**
  23861. * Computes the world matrix
  23862. * @param force Specifies if the world matrix should be computed by force
  23863. * @returns A world matrix
  23864. */
  23865. computeWorldMatrix(force: boolean): Matrix;
  23866. /**
  23867. * Gets the world matrix
  23868. * @returns A world matrix
  23869. */
  23870. getWorldMatrix?(): Matrix;
  23871. /**
  23872. * Gets the child meshes
  23873. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23874. * @returns An array of abstract meshes
  23875. */
  23876. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23877. /**
  23878. * Gets the vertex data
  23879. * @param kind The type of vertex data
  23880. * @returns A nullable array of numbers, or a float32 array
  23881. */
  23882. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23883. /**
  23884. * Gets the indices from the mesh
  23885. * @returns A nullable array of index arrays
  23886. */
  23887. getIndices?(): Nullable<IndicesArray>;
  23888. /**
  23889. * Gets the scene from the mesh
  23890. * @returns the indices array or null
  23891. */
  23892. getScene?(): Scene;
  23893. /**
  23894. * Gets the absolute position from the mesh
  23895. * @returns the absolute position
  23896. */
  23897. getAbsolutePosition(): Vector3;
  23898. /**
  23899. * Gets the absolute pivot point from the mesh
  23900. * @returns the absolute pivot point
  23901. */
  23902. getAbsolutePivotPoint(): Vector3;
  23903. /**
  23904. * Rotates the mesh
  23905. * @param axis The axis of rotation
  23906. * @param amount The amount of rotation
  23907. * @param space The space of the rotation
  23908. * @returns The rotation transform node
  23909. */
  23910. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23911. /**
  23912. * Translates the mesh
  23913. * @param axis The axis of translation
  23914. * @param distance The distance of translation
  23915. * @param space The space of the translation
  23916. * @returns The transform node
  23917. */
  23918. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23919. /**
  23920. * Sets the absolute position of the mesh
  23921. * @param absolutePosition The absolute position of the mesh
  23922. * @returns The transform node
  23923. */
  23924. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23925. /**
  23926. * Gets the class name of the mesh
  23927. * @returns The class name
  23928. */
  23929. getClassName(): string;
  23930. }
  23931. /**
  23932. * Represents a physics imposter
  23933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23934. */
  23935. export class PhysicsImpostor {
  23936. /**
  23937. * The physics-enabled object used as the physics imposter
  23938. */
  23939. object: IPhysicsEnabledObject;
  23940. /**
  23941. * The type of the physics imposter
  23942. */
  23943. type: number;
  23944. private _options;
  23945. private _scene?;
  23946. /**
  23947. * The default object size of the imposter
  23948. */
  23949. static DEFAULT_OBJECT_SIZE: Vector3;
  23950. /**
  23951. * The identity quaternion of the imposter
  23952. */
  23953. static IDENTITY_QUATERNION: Quaternion;
  23954. /** @hidden */
  23955. _pluginData: any;
  23956. private _physicsEngine;
  23957. private _physicsBody;
  23958. private _bodyUpdateRequired;
  23959. private _onBeforePhysicsStepCallbacks;
  23960. private _onAfterPhysicsStepCallbacks;
  23961. /** @hidden */
  23962. _onPhysicsCollideCallbacks: Array<{
  23963. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23964. otherImpostors: Array<PhysicsImpostor>;
  23965. }>;
  23966. private _deltaPosition;
  23967. private _deltaRotation;
  23968. private _deltaRotationConjugated;
  23969. /** @hidden */
  23970. _isFromLine: boolean;
  23971. private _parent;
  23972. private _isDisposed;
  23973. private static _tmpVecs;
  23974. private static _tmpQuat;
  23975. /**
  23976. * Specifies if the physics imposter is disposed
  23977. */
  23978. get isDisposed(): boolean;
  23979. /**
  23980. * Gets the mass of the physics imposter
  23981. */
  23982. get mass(): number;
  23983. set mass(value: number);
  23984. /**
  23985. * Gets the coefficient of friction
  23986. */
  23987. get friction(): number;
  23988. /**
  23989. * Sets the coefficient of friction
  23990. */
  23991. set friction(value: number);
  23992. /**
  23993. * Gets the coefficient of restitution
  23994. */
  23995. get restitution(): number;
  23996. /**
  23997. * Sets the coefficient of restitution
  23998. */
  23999. set restitution(value: number);
  24000. /**
  24001. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24002. */
  24003. get pressure(): number;
  24004. /**
  24005. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24006. */
  24007. set pressure(value: number);
  24008. /**
  24009. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24010. */
  24011. get stiffness(): number;
  24012. /**
  24013. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24014. */
  24015. set stiffness(value: number);
  24016. /**
  24017. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24018. */
  24019. get velocityIterations(): number;
  24020. /**
  24021. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24022. */
  24023. set velocityIterations(value: number);
  24024. /**
  24025. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24026. */
  24027. get positionIterations(): number;
  24028. /**
  24029. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24030. */
  24031. set positionIterations(value: number);
  24032. /**
  24033. * The unique id of the physics imposter
  24034. * set by the physics engine when adding this impostor to the array
  24035. */
  24036. uniqueId: number;
  24037. /**
  24038. * @hidden
  24039. */
  24040. soft: boolean;
  24041. /**
  24042. * @hidden
  24043. */
  24044. segments: number;
  24045. private _joints;
  24046. /**
  24047. * Initializes the physics imposter
  24048. * @param object The physics-enabled object used as the physics imposter
  24049. * @param type The type of the physics imposter
  24050. * @param _options The options for the physics imposter
  24051. * @param _scene The Babylon scene
  24052. */
  24053. constructor(
  24054. /**
  24055. * The physics-enabled object used as the physics imposter
  24056. */
  24057. object: IPhysicsEnabledObject,
  24058. /**
  24059. * The type of the physics imposter
  24060. */
  24061. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24062. /**
  24063. * This function will completly initialize this impostor.
  24064. * It will create a new body - but only if this mesh has no parent.
  24065. * If it has, this impostor will not be used other than to define the impostor
  24066. * of the child mesh.
  24067. * @hidden
  24068. */
  24069. _init(): void;
  24070. private _getPhysicsParent;
  24071. /**
  24072. * Should a new body be generated.
  24073. * @returns boolean specifying if body initialization is required
  24074. */
  24075. isBodyInitRequired(): boolean;
  24076. /**
  24077. * Sets the updated scaling
  24078. * @param updated Specifies if the scaling is updated
  24079. */
  24080. setScalingUpdated(): void;
  24081. /**
  24082. * Force a regeneration of this or the parent's impostor's body.
  24083. * Use under cautious - This will remove all joints already implemented.
  24084. */
  24085. forceUpdate(): void;
  24086. /**
  24087. * Gets the body that holds this impostor. Either its own, or its parent.
  24088. */
  24089. get physicsBody(): any;
  24090. /**
  24091. * Get the parent of the physics imposter
  24092. * @returns Physics imposter or null
  24093. */
  24094. get parent(): Nullable<PhysicsImpostor>;
  24095. /**
  24096. * Sets the parent of the physics imposter
  24097. */
  24098. set parent(value: Nullable<PhysicsImpostor>);
  24099. /**
  24100. * Set the physics body. Used mainly by the physics engine/plugin
  24101. */
  24102. set physicsBody(physicsBody: any);
  24103. /**
  24104. * Resets the update flags
  24105. */
  24106. resetUpdateFlags(): void;
  24107. /**
  24108. * Gets the object extend size
  24109. * @returns the object extend size
  24110. */
  24111. getObjectExtendSize(): Vector3;
  24112. /**
  24113. * Gets the object center
  24114. * @returns The object center
  24115. */
  24116. getObjectCenter(): Vector3;
  24117. /**
  24118. * Get a specific parameter from the options parameters
  24119. * @param paramName The object parameter name
  24120. * @returns The object parameter
  24121. */
  24122. getParam(paramName: string): any;
  24123. /**
  24124. * Sets a specific parameter in the options given to the physics plugin
  24125. * @param paramName The parameter name
  24126. * @param value The value of the parameter
  24127. */
  24128. setParam(paramName: string, value: number): void;
  24129. /**
  24130. * Specifically change the body's mass option. Won't recreate the physics body object
  24131. * @param mass The mass of the physics imposter
  24132. */
  24133. setMass(mass: number): void;
  24134. /**
  24135. * Gets the linear velocity
  24136. * @returns linear velocity or null
  24137. */
  24138. getLinearVelocity(): Nullable<Vector3>;
  24139. /**
  24140. * Sets the linear velocity
  24141. * @param velocity linear velocity or null
  24142. */
  24143. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24144. /**
  24145. * Gets the angular velocity
  24146. * @returns angular velocity or null
  24147. */
  24148. getAngularVelocity(): Nullable<Vector3>;
  24149. /**
  24150. * Sets the angular velocity
  24151. * @param velocity The velocity or null
  24152. */
  24153. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24154. /**
  24155. * Execute a function with the physics plugin native code
  24156. * Provide a function the will have two variables - the world object and the physics body object
  24157. * @param func The function to execute with the physics plugin native code
  24158. */
  24159. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24160. /**
  24161. * Register a function that will be executed before the physics world is stepping forward
  24162. * @param func The function to execute before the physics world is stepped forward
  24163. */
  24164. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24165. /**
  24166. * Unregister a function that will be executed before the physics world is stepping forward
  24167. * @param func The function to execute before the physics world is stepped forward
  24168. */
  24169. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24170. /**
  24171. * Register a function that will be executed after the physics step
  24172. * @param func The function to execute after physics step
  24173. */
  24174. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24175. /**
  24176. * Unregisters a function that will be executed after the physics step
  24177. * @param func The function to execute after physics step
  24178. */
  24179. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24180. /**
  24181. * register a function that will be executed when this impostor collides against a different body
  24182. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24183. * @param func Callback that is executed on collision
  24184. */
  24185. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24186. /**
  24187. * Unregisters the physics imposter on contact
  24188. * @param collideAgainst The physics object to collide against
  24189. * @param func Callback to execute on collision
  24190. */
  24191. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24192. private _tmpQuat;
  24193. private _tmpQuat2;
  24194. /**
  24195. * Get the parent rotation
  24196. * @returns The parent rotation
  24197. */
  24198. getParentsRotation(): Quaternion;
  24199. /**
  24200. * this function is executed by the physics engine.
  24201. */
  24202. beforeStep: () => void;
  24203. /**
  24204. * this function is executed by the physics engine
  24205. */
  24206. afterStep: () => void;
  24207. /**
  24208. * Legacy collision detection event support
  24209. */
  24210. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24211. /**
  24212. * event and body object due to cannon's event-based architecture.
  24213. */
  24214. onCollide: (e: {
  24215. body: any;
  24216. }) => void;
  24217. /**
  24218. * Apply a force
  24219. * @param force The force to apply
  24220. * @param contactPoint The contact point for the force
  24221. * @returns The physics imposter
  24222. */
  24223. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24224. /**
  24225. * Apply an impulse
  24226. * @param force The impulse force
  24227. * @param contactPoint The contact point for the impulse force
  24228. * @returns The physics imposter
  24229. */
  24230. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24231. /**
  24232. * A help function to create a joint
  24233. * @param otherImpostor A physics imposter used to create a joint
  24234. * @param jointType The type of joint
  24235. * @param jointData The data for the joint
  24236. * @returns The physics imposter
  24237. */
  24238. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24239. /**
  24240. * Add a joint to this impostor with a different impostor
  24241. * @param otherImpostor A physics imposter used to add a joint
  24242. * @param joint The joint to add
  24243. * @returns The physics imposter
  24244. */
  24245. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24246. /**
  24247. * Add an anchor to a cloth impostor
  24248. * @param otherImpostor rigid impostor to anchor to
  24249. * @param width ratio across width from 0 to 1
  24250. * @param height ratio up height from 0 to 1
  24251. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24252. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24253. * @returns impostor the soft imposter
  24254. */
  24255. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24256. /**
  24257. * Add a hook to a rope impostor
  24258. * @param otherImpostor rigid impostor to anchor to
  24259. * @param length ratio across rope from 0 to 1
  24260. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24261. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24262. * @returns impostor the rope imposter
  24263. */
  24264. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24265. /**
  24266. * Will keep this body still, in a sleep mode.
  24267. * @returns the physics imposter
  24268. */
  24269. sleep(): PhysicsImpostor;
  24270. /**
  24271. * Wake the body up.
  24272. * @returns The physics imposter
  24273. */
  24274. wakeUp(): PhysicsImpostor;
  24275. /**
  24276. * Clones the physics imposter
  24277. * @param newObject The physics imposter clones to this physics-enabled object
  24278. * @returns A nullable physics imposter
  24279. */
  24280. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24281. /**
  24282. * Disposes the physics imposter
  24283. */
  24284. dispose(): void;
  24285. /**
  24286. * Sets the delta position
  24287. * @param position The delta position amount
  24288. */
  24289. setDeltaPosition(position: Vector3): void;
  24290. /**
  24291. * Sets the delta rotation
  24292. * @param rotation The delta rotation amount
  24293. */
  24294. setDeltaRotation(rotation: Quaternion): void;
  24295. /**
  24296. * Gets the box size of the physics imposter and stores the result in the input parameter
  24297. * @param result Stores the box size
  24298. * @returns The physics imposter
  24299. */
  24300. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24301. /**
  24302. * Gets the radius of the physics imposter
  24303. * @returns Radius of the physics imposter
  24304. */
  24305. getRadius(): number;
  24306. /**
  24307. * Sync a bone with this impostor
  24308. * @param bone The bone to sync to the impostor.
  24309. * @param boneMesh The mesh that the bone is influencing.
  24310. * @param jointPivot The pivot of the joint / bone in local space.
  24311. * @param distToJoint Optional distance from the impostor to the joint.
  24312. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24313. */
  24314. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24315. /**
  24316. * Sync impostor to a bone
  24317. * @param bone The bone that the impostor will be synced to.
  24318. * @param boneMesh The mesh that the bone is influencing.
  24319. * @param jointPivot The pivot of the joint / bone in local space.
  24320. * @param distToJoint Optional distance from the impostor to the joint.
  24321. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24322. * @param boneAxis Optional vector3 axis the bone is aligned with
  24323. */
  24324. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24325. /**
  24326. * No-Imposter type
  24327. */
  24328. static NoImpostor: number;
  24329. /**
  24330. * Sphere-Imposter type
  24331. */
  24332. static SphereImpostor: number;
  24333. /**
  24334. * Box-Imposter type
  24335. */
  24336. static BoxImpostor: number;
  24337. /**
  24338. * Plane-Imposter type
  24339. */
  24340. static PlaneImpostor: number;
  24341. /**
  24342. * Mesh-imposter type
  24343. */
  24344. static MeshImpostor: number;
  24345. /**
  24346. * Capsule-Impostor type (Ammo.js plugin only)
  24347. */
  24348. static CapsuleImpostor: number;
  24349. /**
  24350. * Cylinder-Imposter type
  24351. */
  24352. static CylinderImpostor: number;
  24353. /**
  24354. * Particle-Imposter type
  24355. */
  24356. static ParticleImpostor: number;
  24357. /**
  24358. * Heightmap-Imposter type
  24359. */
  24360. static HeightmapImpostor: number;
  24361. /**
  24362. * ConvexHull-Impostor type (Ammo.js plugin only)
  24363. */
  24364. static ConvexHullImpostor: number;
  24365. /**
  24366. * Custom-Imposter type (Ammo.js plugin only)
  24367. */
  24368. static CustomImpostor: number;
  24369. /**
  24370. * Rope-Imposter type
  24371. */
  24372. static RopeImpostor: number;
  24373. /**
  24374. * Cloth-Imposter type
  24375. */
  24376. static ClothImpostor: number;
  24377. /**
  24378. * Softbody-Imposter type
  24379. */
  24380. static SoftbodyImpostor: number;
  24381. }
  24382. }
  24383. declare module BABYLON {
  24384. /**
  24385. * @hidden
  24386. **/
  24387. export class _CreationDataStorage {
  24388. closePath?: boolean;
  24389. closeArray?: boolean;
  24390. idx: number[];
  24391. dashSize: number;
  24392. gapSize: number;
  24393. path3D: Path3D;
  24394. pathArray: Vector3[][];
  24395. arc: number;
  24396. radius: number;
  24397. cap: number;
  24398. tessellation: number;
  24399. }
  24400. /**
  24401. * @hidden
  24402. **/
  24403. class _InstanceDataStorage {
  24404. visibleInstances: any;
  24405. batchCache: _InstancesBatch;
  24406. instancesBufferSize: number;
  24407. instancesBuffer: Nullable<Buffer>;
  24408. instancesData: Float32Array;
  24409. overridenInstanceCount: number;
  24410. isFrozen: boolean;
  24411. previousBatch: Nullable<_InstancesBatch>;
  24412. hardwareInstancedRendering: boolean;
  24413. sideOrientation: number;
  24414. manualUpdate: boolean;
  24415. }
  24416. /**
  24417. * @hidden
  24418. **/
  24419. export class _InstancesBatch {
  24420. mustReturn: boolean;
  24421. visibleInstances: Nullable<InstancedMesh[]>[];
  24422. renderSelf: boolean[];
  24423. hardwareInstancedRendering: boolean[];
  24424. }
  24425. /**
  24426. * Class used to represent renderable models
  24427. */
  24428. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24429. /**
  24430. * Mesh side orientation : usually the external or front surface
  24431. */
  24432. static readonly FRONTSIDE: number;
  24433. /**
  24434. * Mesh side orientation : usually the internal or back surface
  24435. */
  24436. static readonly BACKSIDE: number;
  24437. /**
  24438. * Mesh side orientation : both internal and external or front and back surfaces
  24439. */
  24440. static readonly DOUBLESIDE: number;
  24441. /**
  24442. * Mesh side orientation : by default, `FRONTSIDE`
  24443. */
  24444. static readonly DEFAULTSIDE: number;
  24445. /**
  24446. * Mesh cap setting : no cap
  24447. */
  24448. static readonly NO_CAP: number;
  24449. /**
  24450. * Mesh cap setting : one cap at the beginning of the mesh
  24451. */
  24452. static readonly CAP_START: number;
  24453. /**
  24454. * Mesh cap setting : one cap at the end of the mesh
  24455. */
  24456. static readonly CAP_END: number;
  24457. /**
  24458. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24459. */
  24460. static readonly CAP_ALL: number;
  24461. /**
  24462. * Mesh pattern setting : no flip or rotate
  24463. */
  24464. static readonly NO_FLIP: number;
  24465. /**
  24466. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24467. */
  24468. static readonly FLIP_TILE: number;
  24469. /**
  24470. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24471. */
  24472. static readonly ROTATE_TILE: number;
  24473. /**
  24474. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24475. */
  24476. static readonly FLIP_ROW: number;
  24477. /**
  24478. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24479. */
  24480. static readonly ROTATE_ROW: number;
  24481. /**
  24482. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24483. */
  24484. static readonly FLIP_N_ROTATE_TILE: number;
  24485. /**
  24486. * Mesh pattern setting : rotate pattern and rotate
  24487. */
  24488. static readonly FLIP_N_ROTATE_ROW: number;
  24489. /**
  24490. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24491. */
  24492. static readonly CENTER: number;
  24493. /**
  24494. * Mesh tile positioning : part tiles on left
  24495. */
  24496. static readonly LEFT: number;
  24497. /**
  24498. * Mesh tile positioning : part tiles on right
  24499. */
  24500. static readonly RIGHT: number;
  24501. /**
  24502. * Mesh tile positioning : part tiles on top
  24503. */
  24504. static readonly TOP: number;
  24505. /**
  24506. * Mesh tile positioning : part tiles on bottom
  24507. */
  24508. static readonly BOTTOM: number;
  24509. /**
  24510. * Gets the default side orientation.
  24511. * @param orientation the orientation to value to attempt to get
  24512. * @returns the default orientation
  24513. * @hidden
  24514. */
  24515. static _GetDefaultSideOrientation(orientation?: number): number;
  24516. private _internalMeshDataInfo;
  24517. /**
  24518. * An event triggered before rendering the mesh
  24519. */
  24520. get onBeforeRenderObservable(): Observable<Mesh>;
  24521. /**
  24522. * An event triggered before binding the mesh
  24523. */
  24524. get onBeforeBindObservable(): Observable<Mesh>;
  24525. /**
  24526. * An event triggered after rendering the mesh
  24527. */
  24528. get onAfterRenderObservable(): Observable<Mesh>;
  24529. /**
  24530. * An event triggered before drawing the mesh
  24531. */
  24532. get onBeforeDrawObservable(): Observable<Mesh>;
  24533. private _onBeforeDrawObserver;
  24534. /**
  24535. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24536. */
  24537. set onBeforeDraw(callback: () => void);
  24538. get hasInstances(): boolean;
  24539. /**
  24540. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24541. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24542. */
  24543. delayLoadState: number;
  24544. /**
  24545. * Gets the list of instances created from this mesh
  24546. * it is not supposed to be modified manually.
  24547. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24548. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24549. */
  24550. instances: InstancedMesh[];
  24551. /**
  24552. * Gets the file containing delay loading data for this mesh
  24553. */
  24554. delayLoadingFile: string;
  24555. /** @hidden */
  24556. _binaryInfo: any;
  24557. /**
  24558. * User defined function used to change how LOD level selection is done
  24559. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24560. */
  24561. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24562. /**
  24563. * Gets or sets the morph target manager
  24564. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24565. */
  24566. get morphTargetManager(): Nullable<MorphTargetManager>;
  24567. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24568. /** @hidden */
  24569. _creationDataStorage: Nullable<_CreationDataStorage>;
  24570. /** @hidden */
  24571. _geometry: Nullable<Geometry>;
  24572. /** @hidden */
  24573. _delayInfo: Array<string>;
  24574. /** @hidden */
  24575. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24576. /** @hidden */
  24577. _instanceDataStorage: _InstanceDataStorage;
  24578. private _effectiveMaterial;
  24579. /** @hidden */
  24580. _shouldGenerateFlatShading: boolean;
  24581. /** @hidden */
  24582. _originalBuilderSideOrientation: number;
  24583. /**
  24584. * Use this property to change the original side orientation defined at construction time
  24585. */
  24586. overrideMaterialSideOrientation: Nullable<number>;
  24587. /**
  24588. * Gets the source mesh (the one used to clone this one from)
  24589. */
  24590. get source(): Nullable<Mesh>;
  24591. /**
  24592. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24593. */
  24594. get isUnIndexed(): boolean;
  24595. set isUnIndexed(value: boolean);
  24596. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24597. get worldMatrixInstancedBuffer(): Float32Array;
  24598. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24599. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24600. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24601. /**
  24602. * @constructor
  24603. * @param name The value used by scene.getMeshByName() to do a lookup.
  24604. * @param scene The scene to add this mesh to.
  24605. * @param parent The parent of this mesh, if it has one
  24606. * @param source An optional Mesh from which geometry is shared, cloned.
  24607. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24608. * When false, achieved by calling a clone(), also passing False.
  24609. * This will make creation of children, recursive.
  24610. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24611. */
  24612. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24613. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24614. doNotInstantiate: boolean;
  24615. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24616. /**
  24617. * Gets the class name
  24618. * @returns the string "Mesh".
  24619. */
  24620. getClassName(): string;
  24621. /** @hidden */
  24622. get _isMesh(): boolean;
  24623. /**
  24624. * Returns a description of this mesh
  24625. * @param fullDetails define if full details about this mesh must be used
  24626. * @returns a descriptive string representing this mesh
  24627. */
  24628. toString(fullDetails?: boolean): string;
  24629. /** @hidden */
  24630. _unBindEffect(): void;
  24631. /**
  24632. * Gets a boolean indicating if this mesh has LOD
  24633. */
  24634. get hasLODLevels(): boolean;
  24635. /**
  24636. * Gets the list of MeshLODLevel associated with the current mesh
  24637. * @returns an array of MeshLODLevel
  24638. */
  24639. getLODLevels(): MeshLODLevel[];
  24640. private _sortLODLevels;
  24641. /**
  24642. * Add a mesh as LOD level triggered at the given distance.
  24643. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24644. * @param distance The distance from the center of the object to show this level
  24645. * @param mesh The mesh to be added as LOD level (can be null)
  24646. * @return This mesh (for chaining)
  24647. */
  24648. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24649. /**
  24650. * Returns the LOD level mesh at the passed distance or null if not found.
  24651. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24652. * @param distance The distance from the center of the object to show this level
  24653. * @returns a Mesh or `null`
  24654. */
  24655. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24656. /**
  24657. * Remove a mesh from the LOD array
  24658. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24659. * @param mesh defines the mesh to be removed
  24660. * @return This mesh (for chaining)
  24661. */
  24662. removeLODLevel(mesh: Mesh): Mesh;
  24663. /**
  24664. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24665. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24666. * @param camera defines the camera to use to compute distance
  24667. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24668. * @return This mesh (for chaining)
  24669. */
  24670. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24671. /**
  24672. * Gets the mesh internal Geometry object
  24673. */
  24674. get geometry(): Nullable<Geometry>;
  24675. /**
  24676. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24677. * @returns the total number of vertices
  24678. */
  24679. getTotalVertices(): number;
  24680. /**
  24681. * Returns the content of an associated vertex buffer
  24682. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24683. * - VertexBuffer.PositionKind
  24684. * - VertexBuffer.UVKind
  24685. * - VertexBuffer.UV2Kind
  24686. * - VertexBuffer.UV3Kind
  24687. * - VertexBuffer.UV4Kind
  24688. * - VertexBuffer.UV5Kind
  24689. * - VertexBuffer.UV6Kind
  24690. * - VertexBuffer.ColorKind
  24691. * - VertexBuffer.MatricesIndicesKind
  24692. * - VertexBuffer.MatricesIndicesExtraKind
  24693. * - VertexBuffer.MatricesWeightsKind
  24694. * - VertexBuffer.MatricesWeightsExtraKind
  24695. * @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
  24696. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24697. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24698. */
  24699. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24700. /**
  24701. * Returns the mesh VertexBuffer object from the requested `kind`
  24702. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24703. * - VertexBuffer.PositionKind
  24704. * - VertexBuffer.NormalKind
  24705. * - VertexBuffer.UVKind
  24706. * - VertexBuffer.UV2Kind
  24707. * - VertexBuffer.UV3Kind
  24708. * - VertexBuffer.UV4Kind
  24709. * - VertexBuffer.UV5Kind
  24710. * - VertexBuffer.UV6Kind
  24711. * - VertexBuffer.ColorKind
  24712. * - VertexBuffer.MatricesIndicesKind
  24713. * - VertexBuffer.MatricesIndicesExtraKind
  24714. * - VertexBuffer.MatricesWeightsKind
  24715. * - VertexBuffer.MatricesWeightsExtraKind
  24716. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24717. */
  24718. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24719. /**
  24720. * Tests if a specific vertex buffer is associated with this mesh
  24721. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24722. * - VertexBuffer.PositionKind
  24723. * - VertexBuffer.NormalKind
  24724. * - VertexBuffer.UVKind
  24725. * - VertexBuffer.UV2Kind
  24726. * - VertexBuffer.UV3Kind
  24727. * - VertexBuffer.UV4Kind
  24728. * - VertexBuffer.UV5Kind
  24729. * - VertexBuffer.UV6Kind
  24730. * - VertexBuffer.ColorKind
  24731. * - VertexBuffer.MatricesIndicesKind
  24732. * - VertexBuffer.MatricesIndicesExtraKind
  24733. * - VertexBuffer.MatricesWeightsKind
  24734. * - VertexBuffer.MatricesWeightsExtraKind
  24735. * @returns a boolean
  24736. */
  24737. isVerticesDataPresent(kind: string): boolean;
  24738. /**
  24739. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24740. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24741. * - VertexBuffer.PositionKind
  24742. * - VertexBuffer.UVKind
  24743. * - VertexBuffer.UV2Kind
  24744. * - VertexBuffer.UV3Kind
  24745. * - VertexBuffer.UV4Kind
  24746. * - VertexBuffer.UV5Kind
  24747. * - VertexBuffer.UV6Kind
  24748. * - VertexBuffer.ColorKind
  24749. * - VertexBuffer.MatricesIndicesKind
  24750. * - VertexBuffer.MatricesIndicesExtraKind
  24751. * - VertexBuffer.MatricesWeightsKind
  24752. * - VertexBuffer.MatricesWeightsExtraKind
  24753. * @returns a boolean
  24754. */
  24755. isVertexBufferUpdatable(kind: string): boolean;
  24756. /**
  24757. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24758. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24759. * - VertexBuffer.PositionKind
  24760. * - VertexBuffer.NormalKind
  24761. * - VertexBuffer.UVKind
  24762. * - VertexBuffer.UV2Kind
  24763. * - VertexBuffer.UV3Kind
  24764. * - VertexBuffer.UV4Kind
  24765. * - VertexBuffer.UV5Kind
  24766. * - VertexBuffer.UV6Kind
  24767. * - VertexBuffer.ColorKind
  24768. * - VertexBuffer.MatricesIndicesKind
  24769. * - VertexBuffer.MatricesIndicesExtraKind
  24770. * - VertexBuffer.MatricesWeightsKind
  24771. * - VertexBuffer.MatricesWeightsExtraKind
  24772. * @returns an array of strings
  24773. */
  24774. getVerticesDataKinds(): string[];
  24775. /**
  24776. * Returns a positive integer : the total number of indices in this mesh geometry.
  24777. * @returns the numner of indices or zero if the mesh has no geometry.
  24778. */
  24779. getTotalIndices(): number;
  24780. /**
  24781. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24782. * @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.
  24783. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24784. * @returns the indices array or an empty array if the mesh has no geometry
  24785. */
  24786. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24787. get isBlocked(): boolean;
  24788. /**
  24789. * Determine if the current mesh is ready to be rendered
  24790. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24791. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24792. * @returns true if all associated assets are ready (material, textures, shaders)
  24793. */
  24794. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24795. /**
  24796. * 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.
  24797. */
  24798. get areNormalsFrozen(): boolean;
  24799. /**
  24800. * 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.
  24801. * @returns the current mesh
  24802. */
  24803. freezeNormals(): Mesh;
  24804. /**
  24805. * 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
  24806. * @returns the current mesh
  24807. */
  24808. unfreezeNormals(): Mesh;
  24809. /**
  24810. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24811. */
  24812. set overridenInstanceCount(count: number);
  24813. /** @hidden */
  24814. _preActivate(): Mesh;
  24815. /** @hidden */
  24816. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24817. /** @hidden */
  24818. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24819. /**
  24820. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24821. * This means the mesh underlying bounding box and sphere are recomputed.
  24822. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24823. * @returns the current mesh
  24824. */
  24825. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24826. /** @hidden */
  24827. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24828. /**
  24829. * This function will subdivide the mesh into multiple submeshes
  24830. * @param count defines the expected number of submeshes
  24831. */
  24832. subdivide(count: number): void;
  24833. /**
  24834. * Copy a FloatArray into a specific associated vertex buffer
  24835. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24836. * - VertexBuffer.PositionKind
  24837. * - VertexBuffer.UVKind
  24838. * - VertexBuffer.UV2Kind
  24839. * - VertexBuffer.UV3Kind
  24840. * - VertexBuffer.UV4Kind
  24841. * - VertexBuffer.UV5Kind
  24842. * - VertexBuffer.UV6Kind
  24843. * - VertexBuffer.ColorKind
  24844. * - VertexBuffer.MatricesIndicesKind
  24845. * - VertexBuffer.MatricesIndicesExtraKind
  24846. * - VertexBuffer.MatricesWeightsKind
  24847. * - VertexBuffer.MatricesWeightsExtraKind
  24848. * @param data defines the data source
  24849. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24850. * @param stride defines the data stride size (can be null)
  24851. * @returns the current mesh
  24852. */
  24853. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24854. /**
  24855. * Delete a vertex buffer associated with this mesh
  24856. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24857. * - VertexBuffer.PositionKind
  24858. * - VertexBuffer.UVKind
  24859. * - VertexBuffer.UV2Kind
  24860. * - VertexBuffer.UV3Kind
  24861. * - VertexBuffer.UV4Kind
  24862. * - VertexBuffer.UV5Kind
  24863. * - VertexBuffer.UV6Kind
  24864. * - VertexBuffer.ColorKind
  24865. * - VertexBuffer.MatricesIndicesKind
  24866. * - VertexBuffer.MatricesIndicesExtraKind
  24867. * - VertexBuffer.MatricesWeightsKind
  24868. * - VertexBuffer.MatricesWeightsExtraKind
  24869. */
  24870. removeVerticesData(kind: string): void;
  24871. /**
  24872. * Flags an associated vertex buffer as updatable
  24873. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24874. * - VertexBuffer.PositionKind
  24875. * - VertexBuffer.UVKind
  24876. * - VertexBuffer.UV2Kind
  24877. * - VertexBuffer.UV3Kind
  24878. * - VertexBuffer.UV4Kind
  24879. * - VertexBuffer.UV5Kind
  24880. * - VertexBuffer.UV6Kind
  24881. * - VertexBuffer.ColorKind
  24882. * - VertexBuffer.MatricesIndicesKind
  24883. * - VertexBuffer.MatricesIndicesExtraKind
  24884. * - VertexBuffer.MatricesWeightsKind
  24885. * - VertexBuffer.MatricesWeightsExtraKind
  24886. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24887. */
  24888. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24889. /**
  24890. * Sets the mesh global Vertex Buffer
  24891. * @param buffer defines the buffer to use
  24892. * @returns the current mesh
  24893. */
  24894. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24895. /**
  24896. * Update a specific associated vertex buffer
  24897. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24898. * - VertexBuffer.PositionKind
  24899. * - VertexBuffer.UVKind
  24900. * - VertexBuffer.UV2Kind
  24901. * - VertexBuffer.UV3Kind
  24902. * - VertexBuffer.UV4Kind
  24903. * - VertexBuffer.UV5Kind
  24904. * - VertexBuffer.UV6Kind
  24905. * - VertexBuffer.ColorKind
  24906. * - VertexBuffer.MatricesIndicesKind
  24907. * - VertexBuffer.MatricesIndicesExtraKind
  24908. * - VertexBuffer.MatricesWeightsKind
  24909. * - VertexBuffer.MatricesWeightsExtraKind
  24910. * @param data defines the data source
  24911. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24912. * @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)
  24913. * @returns the current mesh
  24914. */
  24915. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24916. /**
  24917. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24918. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24919. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24920. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24921. * @returns the current mesh
  24922. */
  24923. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24924. /**
  24925. * Creates a un-shared specific occurence of the geometry for the mesh.
  24926. * @returns the current mesh
  24927. */
  24928. makeGeometryUnique(): Mesh;
  24929. /**
  24930. * Set the index buffer of this mesh
  24931. * @param indices defines the source data
  24932. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24933. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24934. * @returns the current mesh
  24935. */
  24936. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24937. /**
  24938. * Update the current index buffer
  24939. * @param indices defines the source data
  24940. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24941. * @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)
  24942. * @returns the current mesh
  24943. */
  24944. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24945. /**
  24946. * Invert the geometry to move from a right handed system to a left handed one.
  24947. * @returns the current mesh
  24948. */
  24949. toLeftHanded(): Mesh;
  24950. /** @hidden */
  24951. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24952. /** @hidden */
  24953. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24954. /**
  24955. * Registers for this mesh a javascript function called just before the rendering process
  24956. * @param func defines the function to call before rendering this mesh
  24957. * @returns the current mesh
  24958. */
  24959. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24960. /**
  24961. * Disposes a previously registered javascript function called before the rendering
  24962. * @param func defines the function to remove
  24963. * @returns the current mesh
  24964. */
  24965. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24966. /**
  24967. * Registers for this mesh a javascript function called just after the rendering is complete
  24968. * @param func defines the function to call after rendering this mesh
  24969. * @returns the current mesh
  24970. */
  24971. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24972. /**
  24973. * Disposes a previously registered javascript function called after the rendering.
  24974. * @param func defines the function to remove
  24975. * @returns the current mesh
  24976. */
  24977. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24978. /** @hidden */
  24979. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24980. /** @hidden */
  24981. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24982. /** @hidden */
  24983. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24984. /** @hidden */
  24985. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24986. /** @hidden */
  24987. _rebuild(): void;
  24988. /** @hidden */
  24989. _freeze(): void;
  24990. /** @hidden */
  24991. _unFreeze(): void;
  24992. /**
  24993. * 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
  24994. * @param subMesh defines the subMesh to render
  24995. * @param enableAlphaMode defines if alpha mode can be changed
  24996. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24997. * @returns the current mesh
  24998. */
  24999. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25000. private _onBeforeDraw;
  25001. /**
  25002. * Renormalize the mesh and patch it up if there are no weights
  25003. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25004. * However in the case of zero weights then we set just a single influence to 1.
  25005. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25006. */
  25007. cleanMatrixWeights(): void;
  25008. private normalizeSkinFourWeights;
  25009. private normalizeSkinWeightsAndExtra;
  25010. /**
  25011. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25012. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25013. * the user know there was an issue with importing the mesh
  25014. * @returns a validation object with skinned, valid and report string
  25015. */
  25016. validateSkinning(): {
  25017. skinned: boolean;
  25018. valid: boolean;
  25019. report: string;
  25020. };
  25021. /** @hidden */
  25022. _checkDelayState(): Mesh;
  25023. private _queueLoad;
  25024. /**
  25025. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25026. * A mesh is in the frustum if its bounding box intersects the frustum
  25027. * @param frustumPlanes defines the frustum to test
  25028. * @returns true if the mesh is in the frustum planes
  25029. */
  25030. isInFrustum(frustumPlanes: Plane[]): boolean;
  25031. /**
  25032. * Sets the mesh material by the material or multiMaterial `id` property
  25033. * @param id is a string identifying the material or the multiMaterial
  25034. * @returns the current mesh
  25035. */
  25036. setMaterialByID(id: string): Mesh;
  25037. /**
  25038. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25039. * @returns an array of IAnimatable
  25040. */
  25041. getAnimatables(): IAnimatable[];
  25042. /**
  25043. * Modifies the mesh geometry according to the passed transformation matrix.
  25044. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25045. * The mesh normals are modified using the same transformation.
  25046. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25047. * @param transform defines the transform matrix to use
  25048. * @see http://doc.babylonjs.com/resources/baking_transformations
  25049. * @returns the current mesh
  25050. */
  25051. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25052. /**
  25053. * Modifies the mesh geometry according to its own current World Matrix.
  25054. * The mesh World Matrix is then reset.
  25055. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25057. * @see http://doc.babylonjs.com/resources/baking_transformations
  25058. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25059. * @returns the current mesh
  25060. */
  25061. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25062. /** @hidden */
  25063. get _positions(): Nullable<Vector3[]>;
  25064. /** @hidden */
  25065. _resetPointsArrayCache(): Mesh;
  25066. /** @hidden */
  25067. _generatePointsArray(): boolean;
  25068. /**
  25069. * Returns a new Mesh object generated from the current mesh properties.
  25070. * This method must not get confused with createInstance()
  25071. * @param name is a string, the name given to the new mesh
  25072. * @param newParent can be any Node object (default `null`)
  25073. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25074. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25075. * @returns a new mesh
  25076. */
  25077. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25078. /**
  25079. * Releases resources associated with this mesh.
  25080. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25081. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25082. */
  25083. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25084. /** @hidden */
  25085. _disposeInstanceSpecificData(): void;
  25086. /**
  25087. * Modifies the mesh geometry according to a displacement map.
  25088. * 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.
  25089. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25090. * @param url is a string, the URL from the image file is to be downloaded.
  25091. * @param minHeight is the lower limit of the displacement.
  25092. * @param maxHeight is the upper limit of the displacement.
  25093. * @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.
  25094. * @param uvOffset is an optional vector2 used to offset UV.
  25095. * @param uvScale is an optional vector2 used to scale UV.
  25096. * @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.
  25097. * @returns the Mesh.
  25098. */
  25099. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25100. /**
  25101. * Modifies the mesh geometry according to a displacementMap buffer.
  25102. * 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.
  25103. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25104. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25105. * @param heightMapWidth is the width of the buffer image.
  25106. * @param heightMapHeight is the height of the buffer image.
  25107. * @param minHeight is the lower limit of the displacement.
  25108. * @param maxHeight is the upper limit of the displacement.
  25109. * @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.
  25110. * @param uvOffset is an optional vector2 used to offset UV.
  25111. * @param uvScale is an optional vector2 used to scale UV.
  25112. * @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.
  25113. * @returns the Mesh.
  25114. */
  25115. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25116. /**
  25117. * Modify the mesh to get a flat shading rendering.
  25118. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25119. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25120. * @returns current mesh
  25121. */
  25122. convertToFlatShadedMesh(): Mesh;
  25123. /**
  25124. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25125. * In other words, more vertices, no more indices and a single bigger VBO.
  25126. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25127. * @returns current mesh
  25128. */
  25129. convertToUnIndexedMesh(): Mesh;
  25130. /**
  25131. * Inverses facet orientations.
  25132. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25133. * @param flipNormals will also inverts the normals
  25134. * @returns current mesh
  25135. */
  25136. flipFaces(flipNormals?: boolean): Mesh;
  25137. /**
  25138. * Increase the number of facets and hence vertices in a mesh
  25139. * Vertex normals are interpolated from existing vertex normals
  25140. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25141. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25142. */
  25143. increaseVertices(numberPerEdge: number): void;
  25144. /**
  25145. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25146. * This will undo any application of covertToFlatShadedMesh
  25147. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25148. */
  25149. forceSharedVertices(): void;
  25150. /** @hidden */
  25151. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25152. /** @hidden */
  25153. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25154. /**
  25155. * Creates a new InstancedMesh object from the mesh model.
  25156. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25157. * @param name defines the name of the new instance
  25158. * @returns a new InstancedMesh
  25159. */
  25160. createInstance(name: string): InstancedMesh;
  25161. /**
  25162. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25163. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25164. * @returns the current mesh
  25165. */
  25166. synchronizeInstances(): Mesh;
  25167. /**
  25168. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25169. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25170. * This should be used together with the simplification to avoid disappearing triangles.
  25171. * @param successCallback an optional success callback to be called after the optimization finished.
  25172. * @returns the current mesh
  25173. */
  25174. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25175. /**
  25176. * Serialize current mesh
  25177. * @param serializationObject defines the object which will receive the serialization data
  25178. */
  25179. serialize(serializationObject: any): void;
  25180. /** @hidden */
  25181. _syncGeometryWithMorphTargetManager(): void;
  25182. /** @hidden */
  25183. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25184. /**
  25185. * Returns a new Mesh object parsed from the source provided.
  25186. * @param parsedMesh is the source
  25187. * @param scene defines the hosting scene
  25188. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25189. * @returns a new Mesh
  25190. */
  25191. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25192. /**
  25193. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25194. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25195. * @param name defines the name of the mesh to create
  25196. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25197. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25198. * @param closePath creates a seam between the first and the last points of each path of the path array
  25199. * @param offset is taken in account only if the `pathArray` is containing a single path
  25200. * @param scene defines the hosting scene
  25201. * @param updatable defines if the mesh must be flagged as updatable
  25202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25203. * @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)
  25204. * @returns a new Mesh
  25205. */
  25206. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25207. /**
  25208. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25209. * @param name defines the name of the mesh to create
  25210. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25211. * @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
  25212. * @param scene defines the hosting scene
  25213. * @param updatable defines if the mesh must be flagged as updatable
  25214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25215. * @returns a new Mesh
  25216. */
  25217. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25218. /**
  25219. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25220. * @param name defines the name of the mesh to create
  25221. * @param size sets the size (float) of each box side (default 1)
  25222. * @param scene defines the hosting scene
  25223. * @param updatable defines if the mesh must be flagged as updatable
  25224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25225. * @returns a new Mesh
  25226. */
  25227. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25228. /**
  25229. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25230. * @param name defines the name of the mesh to create
  25231. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25232. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25233. * @param scene defines the hosting scene
  25234. * @param updatable defines if the mesh must be flagged as updatable
  25235. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25236. * @returns a new Mesh
  25237. */
  25238. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25239. /**
  25240. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25241. * @param name defines the name of the mesh to create
  25242. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25243. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25244. * @param scene defines the hosting scene
  25245. * @returns a new Mesh
  25246. */
  25247. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25248. /**
  25249. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25250. * @param name defines the name of the mesh to create
  25251. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25252. * @param diameterTop set the top cap diameter (floats, default 1)
  25253. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25254. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25255. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25256. * @param scene defines the hosting scene
  25257. * @param updatable defines if the mesh must be flagged as updatable
  25258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25259. * @returns a new Mesh
  25260. */
  25261. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25262. /**
  25263. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25264. * @param name defines the name of the mesh to create
  25265. * @param diameter sets the diameter size (float) of the torus (default 1)
  25266. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25267. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25268. * @param scene defines the hosting scene
  25269. * @param updatable defines if the mesh must be flagged as updatable
  25270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25271. * @returns a new Mesh
  25272. */
  25273. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25274. /**
  25275. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25276. * @param name defines the name of the mesh to create
  25277. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25278. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25279. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25280. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25281. * @param p the number of windings on X axis (positive integers, default 2)
  25282. * @param q the number of windings on Y axis (positive integers, default 3)
  25283. * @param scene defines the hosting scene
  25284. * @param updatable defines if the mesh must be flagged as updatable
  25285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25286. * @returns a new Mesh
  25287. */
  25288. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25289. /**
  25290. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25291. * @param name defines the name of the mesh to create
  25292. * @param points is an array successive Vector3
  25293. * @param scene defines the hosting scene
  25294. * @param updatable defines if the mesh must be flagged as updatable
  25295. * @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).
  25296. * @returns a new Mesh
  25297. */
  25298. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25299. /**
  25300. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25301. * @param name defines the name of the mesh to create
  25302. * @param points is an array successive Vector3
  25303. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25304. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25305. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25306. * @param scene defines the hosting scene
  25307. * @param updatable defines if the mesh must be flagged as updatable
  25308. * @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)
  25309. * @returns a new Mesh
  25310. */
  25311. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25312. /**
  25313. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25314. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25315. * 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.
  25316. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25317. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25318. * Remember you can only change the shape positions, not their number when updating a polygon.
  25319. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25320. * @param name defines the name of the mesh to create
  25321. * @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
  25322. * @param scene defines the hosting scene
  25323. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25324. * @param updatable defines if the mesh must be flagged as updatable
  25325. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25326. * @param earcutInjection can be used to inject your own earcut reference
  25327. * @returns a new Mesh
  25328. */
  25329. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25330. /**
  25331. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25332. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25333. * @param name defines the name of the mesh to create
  25334. * @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
  25335. * @param depth defines the height of extrusion
  25336. * @param scene defines the hosting scene
  25337. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25338. * @param updatable defines if the mesh must be flagged as updatable
  25339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25340. * @param earcutInjection can be used to inject your own earcut reference
  25341. * @returns a new Mesh
  25342. */
  25343. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25344. /**
  25345. * Creates an extruded shape mesh.
  25346. * 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
  25347. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25348. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25349. * @param name defines the name of the mesh to create
  25350. * @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
  25351. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25352. * @param scale is the value to scale the shape
  25353. * @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
  25354. * @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
  25355. * @param scene defines the hosting scene
  25356. * @param updatable defines if the mesh must be flagged as updatable
  25357. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25358. * @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)
  25359. * @returns a new Mesh
  25360. */
  25361. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25362. /**
  25363. * Creates an custom extruded shape mesh.
  25364. * The custom extrusion is a parametric shape.
  25365. * It has no predefined shape. Its final shape will depend on the input parameters.
  25366. * Please consider using the same method from the MeshBuilder class instead
  25367. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25368. * @param name defines the name of the mesh to create
  25369. * @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
  25370. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25371. * @param scaleFunction is a custom Javascript function called on each path point
  25372. * @param rotationFunction is a custom Javascript function called on each path point
  25373. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25374. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25375. * @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
  25376. * @param scene defines the hosting scene
  25377. * @param updatable defines if the mesh must be flagged as updatable
  25378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25379. * @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)
  25380. * @returns a new Mesh
  25381. */
  25382. 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;
  25383. /**
  25384. * Creates lathe mesh.
  25385. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25386. * Please consider using the same method from the MeshBuilder class instead
  25387. * @param name defines the name of the mesh to create
  25388. * @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
  25389. * @param radius is the radius value of the lathe
  25390. * @param tessellation is the side number of the lathe.
  25391. * @param scene defines the hosting scene
  25392. * @param updatable defines if the mesh must be flagged as updatable
  25393. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25394. * @returns a new Mesh
  25395. */
  25396. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25397. /**
  25398. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25399. * @param name defines the name of the mesh to create
  25400. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25401. * @param scene defines the hosting scene
  25402. * @param updatable defines if the mesh must be flagged as updatable
  25403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25404. * @returns a new Mesh
  25405. */
  25406. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25407. /**
  25408. * Creates a ground mesh.
  25409. * Please consider using the same method from the MeshBuilder class instead
  25410. * @param name defines the name of the mesh to create
  25411. * @param width set the width of the ground
  25412. * @param height set the height of the ground
  25413. * @param subdivisions sets the number of subdivisions per side
  25414. * @param scene defines the hosting scene
  25415. * @param updatable defines if the mesh must be flagged as updatable
  25416. * @returns a new Mesh
  25417. */
  25418. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25419. /**
  25420. * Creates a tiled ground mesh.
  25421. * Please consider using the same method from the MeshBuilder class instead
  25422. * @param name defines the name of the mesh to create
  25423. * @param xmin set the ground minimum X coordinate
  25424. * @param zmin set the ground minimum Y coordinate
  25425. * @param xmax set the ground maximum X coordinate
  25426. * @param zmax set the ground maximum Z coordinate
  25427. * @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
  25428. * @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
  25429. * @param scene defines the hosting scene
  25430. * @param updatable defines if the mesh must be flagged as updatable
  25431. * @returns a new Mesh
  25432. */
  25433. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25434. w: number;
  25435. h: number;
  25436. }, precision: {
  25437. w: number;
  25438. h: number;
  25439. }, scene: Scene, updatable?: boolean): Mesh;
  25440. /**
  25441. * Creates a ground mesh from a height map.
  25442. * Please consider using the same method from the MeshBuilder class instead
  25443. * @see http://doc.babylonjs.com/babylon101/height_map
  25444. * @param name defines the name of the mesh to create
  25445. * @param url sets the URL of the height map image resource
  25446. * @param width set the ground width size
  25447. * @param height set the ground height size
  25448. * @param subdivisions sets the number of subdivision per side
  25449. * @param minHeight is the minimum altitude on the ground
  25450. * @param maxHeight is the maximum altitude on the ground
  25451. * @param scene defines the hosting scene
  25452. * @param updatable defines if the mesh must be flagged as updatable
  25453. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25454. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25455. * @returns a new Mesh
  25456. */
  25457. 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;
  25458. /**
  25459. * Creates a tube mesh.
  25460. * The tube is a parametric shape.
  25461. * It has no predefined shape. Its final shape will depend on the input parameters.
  25462. * Please consider using the same method from the MeshBuilder class instead
  25463. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25464. * @param name defines the name of the mesh to create
  25465. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25466. * @param radius sets the tube radius size
  25467. * @param tessellation is the number of sides on the tubular surface
  25468. * @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
  25469. * @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
  25470. * @param scene defines the hosting scene
  25471. * @param updatable defines if the mesh must be flagged as updatable
  25472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25473. * @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)
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25477. (i: number, distance: number): number;
  25478. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25479. /**
  25480. * Creates a polyhedron mesh.
  25481. * Please consider using the same method from the MeshBuilder class instead.
  25482. * * 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
  25483. * * The parameter `size` (positive float, default 1) sets the polygon size
  25484. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25485. * * 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`
  25486. * * 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
  25487. * * 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)`)
  25488. * * 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
  25489. * * 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
  25490. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25491. * * 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
  25492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25493. * @param name defines the name of the mesh to create
  25494. * @param options defines the options used to create the mesh
  25495. * @param scene defines the hosting scene
  25496. * @returns a new Mesh
  25497. */
  25498. static CreatePolyhedron(name: string, options: {
  25499. type?: number;
  25500. size?: number;
  25501. sizeX?: number;
  25502. sizeY?: number;
  25503. sizeZ?: number;
  25504. custom?: any;
  25505. faceUV?: Vector4[];
  25506. faceColors?: Color4[];
  25507. updatable?: boolean;
  25508. sideOrientation?: number;
  25509. }, scene: Scene): Mesh;
  25510. /**
  25511. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25512. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25513. * * 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`)
  25514. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25515. * * 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
  25516. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25517. * * 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
  25518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25519. * @param name defines the name of the mesh
  25520. * @param options defines the options used to create the mesh
  25521. * @param scene defines the hosting scene
  25522. * @returns a new Mesh
  25523. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25524. */
  25525. static CreateIcoSphere(name: string, options: {
  25526. radius?: number;
  25527. flat?: boolean;
  25528. subdivisions?: number;
  25529. sideOrientation?: number;
  25530. updatable?: boolean;
  25531. }, scene: Scene): Mesh;
  25532. /**
  25533. * Creates a decal mesh.
  25534. * Please consider using the same method from the MeshBuilder class instead.
  25535. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25536. * @param name defines the name of the mesh
  25537. * @param sourceMesh defines the mesh receiving the decal
  25538. * @param position sets the position of the decal in world coordinates
  25539. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25540. * @param size sets the decal scaling
  25541. * @param angle sets the angle to rotate the decal
  25542. * @returns a new Mesh
  25543. */
  25544. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25545. /**
  25546. * Prepare internal position array for software CPU skinning
  25547. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25548. */
  25549. setPositionsForCPUSkinning(): Float32Array;
  25550. /**
  25551. * Prepare internal normal array for software CPU skinning
  25552. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25553. */
  25554. setNormalsForCPUSkinning(): Float32Array;
  25555. /**
  25556. * Updates the vertex buffer by applying transformation from the bones
  25557. * @param skeleton defines the skeleton to apply to current mesh
  25558. * @returns the current mesh
  25559. */
  25560. applySkeleton(skeleton: Skeleton): Mesh;
  25561. /**
  25562. * 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
  25563. * @param meshes defines the list of meshes to scan
  25564. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25565. */
  25566. static MinMax(meshes: AbstractMesh[]): {
  25567. min: Vector3;
  25568. max: Vector3;
  25569. };
  25570. /**
  25571. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25572. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25573. * @returns a vector3
  25574. */
  25575. static Center(meshesOrMinMaxVector: {
  25576. min: Vector3;
  25577. max: Vector3;
  25578. } | AbstractMesh[]): Vector3;
  25579. /**
  25580. * Merge the array of meshes into a single mesh for performance reasons.
  25581. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25582. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25583. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25584. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25585. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25586. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25587. * @returns a new mesh
  25588. */
  25589. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25590. /** @hidden */
  25591. addInstance(instance: InstancedMesh): void;
  25592. /** @hidden */
  25593. removeInstance(instance: InstancedMesh): void;
  25594. }
  25595. }
  25596. declare module BABYLON {
  25597. /**
  25598. * This is the base class of all the camera used in the application.
  25599. * @see http://doc.babylonjs.com/features/cameras
  25600. */
  25601. export class Camera extends Node {
  25602. /** @hidden */
  25603. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25604. /**
  25605. * This is the default projection mode used by the cameras.
  25606. * It helps recreating a feeling of perspective and better appreciate depth.
  25607. * This is the best way to simulate real life cameras.
  25608. */
  25609. static readonly PERSPECTIVE_CAMERA: number;
  25610. /**
  25611. * This helps creating camera with an orthographic mode.
  25612. * 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.
  25613. */
  25614. static readonly ORTHOGRAPHIC_CAMERA: number;
  25615. /**
  25616. * This is the default FOV mode for perspective cameras.
  25617. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25618. */
  25619. static readonly FOVMODE_VERTICAL_FIXED: number;
  25620. /**
  25621. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25622. */
  25623. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25624. /**
  25625. * This specifies ther is no need for a camera rig.
  25626. * Basically only one eye is rendered corresponding to the camera.
  25627. */
  25628. static readonly RIG_MODE_NONE: number;
  25629. /**
  25630. * Simulates a camera Rig with one blue eye and one red eye.
  25631. * This can be use with 3d blue and red glasses.
  25632. */
  25633. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25634. /**
  25635. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25636. */
  25637. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25638. /**
  25639. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25640. */
  25641. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25642. /**
  25643. * Defines that both eyes of the camera will be rendered over under each other.
  25644. */
  25645. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25646. /**
  25647. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25648. */
  25649. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25650. /**
  25651. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25652. */
  25653. static readonly RIG_MODE_VR: number;
  25654. /**
  25655. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25656. */
  25657. static readonly RIG_MODE_WEBVR: number;
  25658. /**
  25659. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25660. */
  25661. static readonly RIG_MODE_CUSTOM: number;
  25662. /**
  25663. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25664. */
  25665. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25666. /**
  25667. * Define the input manager associated with the camera.
  25668. */
  25669. inputs: CameraInputsManager<Camera>;
  25670. /** @hidden */
  25671. _position: Vector3;
  25672. /**
  25673. * Define the current local position of the camera in the scene
  25674. */
  25675. get position(): Vector3;
  25676. set position(newPosition: Vector3);
  25677. /**
  25678. * The vector the camera should consider as up.
  25679. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25680. */
  25681. upVector: Vector3;
  25682. /**
  25683. * Define the current limit on the left side for an orthographic camera
  25684. * In scene unit
  25685. */
  25686. orthoLeft: Nullable<number>;
  25687. /**
  25688. * Define the current limit on the right side for an orthographic camera
  25689. * In scene unit
  25690. */
  25691. orthoRight: Nullable<number>;
  25692. /**
  25693. * Define the current limit on the bottom side for an orthographic camera
  25694. * In scene unit
  25695. */
  25696. orthoBottom: Nullable<number>;
  25697. /**
  25698. * Define the current limit on the top side for an orthographic camera
  25699. * In scene unit
  25700. */
  25701. orthoTop: Nullable<number>;
  25702. /**
  25703. * Field Of View is set in Radians. (default is 0.8)
  25704. */
  25705. fov: number;
  25706. /**
  25707. * Define the minimum distance the camera can see from.
  25708. * This is important to note that the depth buffer are not infinite and the closer it starts
  25709. * the more your scene might encounter depth fighting issue.
  25710. */
  25711. minZ: number;
  25712. /**
  25713. * Define the maximum distance the camera can see to.
  25714. * This is important to note that the depth buffer are not infinite and the further it end
  25715. * the more your scene might encounter depth fighting issue.
  25716. */
  25717. maxZ: number;
  25718. /**
  25719. * Define the default inertia of the camera.
  25720. * This helps giving a smooth feeling to the camera movement.
  25721. */
  25722. inertia: number;
  25723. /**
  25724. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25725. */
  25726. mode: number;
  25727. /**
  25728. * Define whether the camera is intermediate.
  25729. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25730. */
  25731. isIntermediate: boolean;
  25732. /**
  25733. * Define the viewport of the camera.
  25734. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25735. */
  25736. viewport: Viewport;
  25737. /**
  25738. * Restricts the camera to viewing objects with the same layerMask.
  25739. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25740. */
  25741. layerMask: number;
  25742. /**
  25743. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25744. */
  25745. fovMode: number;
  25746. /**
  25747. * Rig mode of the camera.
  25748. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25749. * This is normally controlled byt the camera themselves as internal use.
  25750. */
  25751. cameraRigMode: number;
  25752. /**
  25753. * Defines the distance between both "eyes" in case of a RIG
  25754. */
  25755. interaxialDistance: number;
  25756. /**
  25757. * Defines if stereoscopic rendering is done side by side or over under.
  25758. */
  25759. isStereoscopicSideBySide: boolean;
  25760. /**
  25761. * 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
  25762. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25763. * else in the scene. (Eg. security camera)
  25764. *
  25765. * 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)
  25766. */
  25767. customRenderTargets: RenderTargetTexture[];
  25768. /**
  25769. * When set, the camera will render to this render target instead of the default canvas
  25770. *
  25771. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25772. */
  25773. outputRenderTarget: Nullable<RenderTargetTexture>;
  25774. /**
  25775. * Observable triggered when the camera view matrix has changed.
  25776. */
  25777. onViewMatrixChangedObservable: Observable<Camera>;
  25778. /**
  25779. * Observable triggered when the camera Projection matrix has changed.
  25780. */
  25781. onProjectionMatrixChangedObservable: Observable<Camera>;
  25782. /**
  25783. * Observable triggered when the inputs have been processed.
  25784. */
  25785. onAfterCheckInputsObservable: Observable<Camera>;
  25786. /**
  25787. * Observable triggered when reset has been called and applied to the camera.
  25788. */
  25789. onRestoreStateObservable: Observable<Camera>;
  25790. /**
  25791. * Is this camera a part of a rig system?
  25792. */
  25793. isRigCamera: boolean;
  25794. /**
  25795. * If isRigCamera set to true this will be set with the parent camera.
  25796. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25797. */
  25798. rigParent?: Camera;
  25799. /** @hidden */
  25800. _cameraRigParams: any;
  25801. /** @hidden */
  25802. _rigCameras: Camera[];
  25803. /** @hidden */
  25804. _rigPostProcess: Nullable<PostProcess>;
  25805. protected _webvrViewMatrix: Matrix;
  25806. /** @hidden */
  25807. _skipRendering: boolean;
  25808. /** @hidden */
  25809. _projectionMatrix: Matrix;
  25810. /** @hidden */
  25811. _postProcesses: Nullable<PostProcess>[];
  25812. /** @hidden */
  25813. _activeMeshes: SmartArray<AbstractMesh>;
  25814. protected _globalPosition: Vector3;
  25815. /** @hidden */
  25816. _computedViewMatrix: Matrix;
  25817. private _doNotComputeProjectionMatrix;
  25818. private _transformMatrix;
  25819. private _frustumPlanes;
  25820. private _refreshFrustumPlanes;
  25821. private _storedFov;
  25822. private _stateStored;
  25823. /**
  25824. * Instantiates a new camera object.
  25825. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25826. * @see http://doc.babylonjs.com/features/cameras
  25827. * @param name Defines the name of the camera in the scene
  25828. * @param position Defines the position of the camera
  25829. * @param scene Defines the scene the camera belongs too
  25830. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25831. */
  25832. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25833. /**
  25834. * Store current camera state (fov, position, etc..)
  25835. * @returns the camera
  25836. */
  25837. storeState(): Camera;
  25838. /**
  25839. * Restores the camera state values if it has been stored. You must call storeState() first
  25840. */
  25841. protected _restoreStateValues(): boolean;
  25842. /**
  25843. * Restored camera state. You must call storeState() first.
  25844. * @returns true if restored and false otherwise
  25845. */
  25846. restoreState(): boolean;
  25847. /**
  25848. * Gets the class name of the camera.
  25849. * @returns the class name
  25850. */
  25851. getClassName(): string;
  25852. /** @hidden */
  25853. readonly _isCamera: boolean;
  25854. /**
  25855. * Gets a string representation of the camera useful for debug purpose.
  25856. * @param fullDetails Defines that a more verboe level of logging is required
  25857. * @returns the string representation
  25858. */
  25859. toString(fullDetails?: boolean): string;
  25860. /**
  25861. * Gets the current world space position of the camera.
  25862. */
  25863. get globalPosition(): Vector3;
  25864. /**
  25865. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25866. * @returns the active meshe list
  25867. */
  25868. getActiveMeshes(): SmartArray<AbstractMesh>;
  25869. /**
  25870. * Check whether a mesh is part of the current active mesh list of the camera
  25871. * @param mesh Defines the mesh to check
  25872. * @returns true if active, false otherwise
  25873. */
  25874. isActiveMesh(mesh: Mesh): boolean;
  25875. /**
  25876. * Is this camera ready to be used/rendered
  25877. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25878. * @return true if the camera is ready
  25879. */
  25880. isReady(completeCheck?: boolean): boolean;
  25881. /** @hidden */
  25882. _initCache(): void;
  25883. /** @hidden */
  25884. _updateCache(ignoreParentClass?: boolean): void;
  25885. /** @hidden */
  25886. _isSynchronized(): boolean;
  25887. /** @hidden */
  25888. _isSynchronizedViewMatrix(): boolean;
  25889. /** @hidden */
  25890. _isSynchronizedProjectionMatrix(): boolean;
  25891. /**
  25892. * Attach the input controls to a specific dom element to get the input from.
  25893. * @param element Defines the element the controls should be listened from
  25894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25895. */
  25896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25897. /**
  25898. * Detach the current controls from the specified dom element.
  25899. * @param element Defines the element to stop listening the inputs from
  25900. */
  25901. detachControl(element: HTMLElement): void;
  25902. /**
  25903. * Update the camera state according to the different inputs gathered during the frame.
  25904. */
  25905. update(): void;
  25906. /** @hidden */
  25907. _checkInputs(): void;
  25908. /** @hidden */
  25909. get rigCameras(): Camera[];
  25910. /**
  25911. * Gets the post process used by the rig cameras
  25912. */
  25913. get rigPostProcess(): Nullable<PostProcess>;
  25914. /**
  25915. * Internal, gets the first post proces.
  25916. * @returns the first post process to be run on this camera.
  25917. */
  25918. _getFirstPostProcess(): Nullable<PostProcess>;
  25919. private _cascadePostProcessesToRigCams;
  25920. /**
  25921. * Attach a post process to the camera.
  25922. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25923. * @param postProcess The post process to attach to the camera
  25924. * @param insertAt The position of the post process in case several of them are in use in the scene
  25925. * @returns the position the post process has been inserted at
  25926. */
  25927. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25928. /**
  25929. * Detach a post process to the camera.
  25930. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25931. * @param postProcess The post process to detach from the camera
  25932. */
  25933. detachPostProcess(postProcess: PostProcess): void;
  25934. /**
  25935. * Gets the current world matrix of the camera
  25936. */
  25937. getWorldMatrix(): Matrix;
  25938. /** @hidden */
  25939. _getViewMatrix(): Matrix;
  25940. /**
  25941. * Gets the current view matrix of the camera.
  25942. * @param force forces the camera to recompute the matrix without looking at the cached state
  25943. * @returns the view matrix
  25944. */
  25945. getViewMatrix(force?: boolean): Matrix;
  25946. /**
  25947. * Freeze the projection matrix.
  25948. * It will prevent the cache check of the camera projection compute and can speed up perf
  25949. * if no parameter of the camera are meant to change
  25950. * @param projection Defines manually a projection if necessary
  25951. */
  25952. freezeProjectionMatrix(projection?: Matrix): void;
  25953. /**
  25954. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25955. */
  25956. unfreezeProjectionMatrix(): void;
  25957. /**
  25958. * Gets the current projection matrix of the camera.
  25959. * @param force forces the camera to recompute the matrix without looking at the cached state
  25960. * @returns the projection matrix
  25961. */
  25962. getProjectionMatrix(force?: boolean): Matrix;
  25963. /**
  25964. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25965. * @returns a Matrix
  25966. */
  25967. getTransformationMatrix(): Matrix;
  25968. private _updateFrustumPlanes;
  25969. /**
  25970. * Checks if a cullable object (mesh...) is in the camera frustum
  25971. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25972. * @param target The object to check
  25973. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25974. * @returns true if the object is in frustum otherwise false
  25975. */
  25976. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25977. /**
  25978. * Checks if a cullable object (mesh...) is in the camera frustum
  25979. * Unlike isInFrustum this cheks the full bounding box
  25980. * @param target The object to check
  25981. * @returns true if the object is in frustum otherwise false
  25982. */
  25983. isCompletelyInFrustum(target: ICullable): boolean;
  25984. /**
  25985. * Gets a ray in the forward direction from the camera.
  25986. * @param length Defines the length of the ray to create
  25987. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25988. * @param origin Defines the start point of the ray which defaults to the camera position
  25989. * @returns the forward ray
  25990. */
  25991. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25992. /**
  25993. * Releases resources associated with this node.
  25994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25996. */
  25997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25998. /** @hidden */
  25999. _isLeftCamera: boolean;
  26000. /**
  26001. * Gets the left camera of a rig setup in case of Rigged Camera
  26002. */
  26003. get isLeftCamera(): boolean;
  26004. /** @hidden */
  26005. _isRightCamera: boolean;
  26006. /**
  26007. * Gets the right camera of a rig setup in case of Rigged Camera
  26008. */
  26009. get isRightCamera(): boolean;
  26010. /**
  26011. * Gets the left camera of a rig setup in case of Rigged Camera
  26012. */
  26013. get leftCamera(): Nullable<FreeCamera>;
  26014. /**
  26015. * Gets the right camera of a rig setup in case of Rigged Camera
  26016. */
  26017. get rightCamera(): Nullable<FreeCamera>;
  26018. /**
  26019. * Gets the left camera target of a rig setup in case of Rigged Camera
  26020. * @returns the target position
  26021. */
  26022. getLeftTarget(): Nullable<Vector3>;
  26023. /**
  26024. * Gets the right camera target of a rig setup in case of Rigged Camera
  26025. * @returns the target position
  26026. */
  26027. getRightTarget(): Nullable<Vector3>;
  26028. /**
  26029. * @hidden
  26030. */
  26031. setCameraRigMode(mode: number, rigParams: any): void;
  26032. /** @hidden */
  26033. static _setStereoscopicRigMode(camera: Camera): void;
  26034. /** @hidden */
  26035. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26036. /** @hidden */
  26037. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26038. /** @hidden */
  26039. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26040. /** @hidden */
  26041. _getVRProjectionMatrix(): Matrix;
  26042. protected _updateCameraRotationMatrix(): void;
  26043. protected _updateWebVRCameraRotationMatrix(): void;
  26044. /**
  26045. * This function MUST be overwritten by the different WebVR cameras available.
  26046. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26047. * @hidden
  26048. */
  26049. _getWebVRProjectionMatrix(): Matrix;
  26050. /**
  26051. * This function MUST be overwritten by the different WebVR cameras available.
  26052. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26053. * @hidden
  26054. */
  26055. _getWebVRViewMatrix(): Matrix;
  26056. /** @hidden */
  26057. setCameraRigParameter(name: string, value: any): void;
  26058. /**
  26059. * needs to be overridden by children so sub has required properties to be copied
  26060. * @hidden
  26061. */
  26062. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26063. /**
  26064. * May need to be overridden by children
  26065. * @hidden
  26066. */
  26067. _updateRigCameras(): void;
  26068. /** @hidden */
  26069. _setupInputs(): void;
  26070. /**
  26071. * Serialiaze the camera setup to a json represention
  26072. * @returns the JSON representation
  26073. */
  26074. serialize(): any;
  26075. /**
  26076. * Clones the current camera.
  26077. * @param name The cloned camera name
  26078. * @returns the cloned camera
  26079. */
  26080. clone(name: string): Camera;
  26081. /**
  26082. * Gets the direction of the camera relative to a given local axis.
  26083. * @param localAxis Defines the reference axis to provide a relative direction.
  26084. * @return the direction
  26085. */
  26086. getDirection(localAxis: Vector3): Vector3;
  26087. /**
  26088. * Returns the current camera absolute rotation
  26089. */
  26090. get absoluteRotation(): Quaternion;
  26091. /**
  26092. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26093. * @param localAxis Defines the reference axis to provide a relative direction.
  26094. * @param result Defines the vector to store the result in
  26095. */
  26096. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26097. /**
  26098. * Gets a camera constructor for a given camera type
  26099. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26100. * @param name The name of the camera the result will be able to instantiate
  26101. * @param scene The scene the result will construct the camera in
  26102. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26103. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26104. * @returns a factory method to construc the camera
  26105. */
  26106. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26107. /**
  26108. * Compute the world matrix of the camera.
  26109. * @returns the camera world matrix
  26110. */
  26111. computeWorldMatrix(): Matrix;
  26112. /**
  26113. * Parse a JSON and creates the camera from the parsed information
  26114. * @param parsedCamera The JSON to parse
  26115. * @param scene The scene to instantiate the camera in
  26116. * @returns the newly constructed camera
  26117. */
  26118. static Parse(parsedCamera: any, scene: Scene): Camera;
  26119. }
  26120. }
  26121. declare module BABYLON {
  26122. /**
  26123. * Class containing static functions to help procedurally build meshes
  26124. */
  26125. export class DiscBuilder {
  26126. /**
  26127. * Creates a plane polygonal mesh. By default, this is a disc
  26128. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26129. * * 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
  26130. * * 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
  26131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26132. * * 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
  26133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26134. * @param name defines the name of the mesh
  26135. * @param options defines the options used to create the mesh
  26136. * @param scene defines the hosting scene
  26137. * @returns the plane polygonal mesh
  26138. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26139. */
  26140. static CreateDisc(name: string, options: {
  26141. radius?: number;
  26142. tessellation?: number;
  26143. arc?: number;
  26144. updatable?: boolean;
  26145. sideOrientation?: number;
  26146. frontUVs?: Vector4;
  26147. backUVs?: Vector4;
  26148. }, scene?: Nullable<Scene>): Mesh;
  26149. }
  26150. }
  26151. declare module BABYLON {
  26152. /**
  26153. * Options to be used when creating a FresnelParameters.
  26154. */
  26155. export type IFresnelParametersCreationOptions = {
  26156. /**
  26157. * Define the color used on edges (grazing angle)
  26158. */
  26159. leftColor?: Color3;
  26160. /**
  26161. * Define the color used on center
  26162. */
  26163. rightColor?: Color3;
  26164. /**
  26165. * Define bias applied to computed fresnel term
  26166. */
  26167. bias?: number;
  26168. /**
  26169. * Defined the power exponent applied to fresnel term
  26170. */
  26171. power?: number;
  26172. /**
  26173. * Define if the fresnel effect is enable or not.
  26174. */
  26175. isEnabled?: boolean;
  26176. };
  26177. /**
  26178. * Serialized format for FresnelParameters.
  26179. */
  26180. export type IFresnelParametersSerialized = {
  26181. /**
  26182. * Define the color used on edges (grazing angle) [as an array]
  26183. */
  26184. leftColor: number[];
  26185. /**
  26186. * Define the color used on center [as an array]
  26187. */
  26188. rightColor: number[];
  26189. /**
  26190. * Define bias applied to computed fresnel term
  26191. */
  26192. bias: number;
  26193. /**
  26194. * Defined the power exponent applied to fresnel term
  26195. */
  26196. power?: number;
  26197. /**
  26198. * Define if the fresnel effect is enable or not.
  26199. */
  26200. isEnabled: boolean;
  26201. };
  26202. /**
  26203. * This represents all the required information to add a fresnel effect on a material:
  26204. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26205. */
  26206. export class FresnelParameters {
  26207. private _isEnabled;
  26208. /**
  26209. * Define if the fresnel effect is enable or not.
  26210. */
  26211. get isEnabled(): boolean;
  26212. set isEnabled(value: boolean);
  26213. /**
  26214. * Define the color used on edges (grazing angle)
  26215. */
  26216. leftColor: Color3;
  26217. /**
  26218. * Define the color used on center
  26219. */
  26220. rightColor: Color3;
  26221. /**
  26222. * Define bias applied to computed fresnel term
  26223. */
  26224. bias: number;
  26225. /**
  26226. * Defined the power exponent applied to fresnel term
  26227. */
  26228. power: number;
  26229. /**
  26230. * Creates a new FresnelParameters object.
  26231. *
  26232. * @param options provide your own settings to optionally to override defaults
  26233. */
  26234. constructor(options?: IFresnelParametersCreationOptions);
  26235. /**
  26236. * Clones the current fresnel and its valuues
  26237. * @returns a clone fresnel configuration
  26238. */
  26239. clone(): FresnelParameters;
  26240. /**
  26241. * Determines equality between FresnelParameters objects
  26242. * @param otherFresnelParameters defines the second operand
  26243. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26244. */
  26245. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26246. /**
  26247. * Serializes the current fresnel parameters to a JSON representation.
  26248. * @return the JSON serialization
  26249. */
  26250. serialize(): IFresnelParametersSerialized;
  26251. /**
  26252. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26253. * @param parsedFresnelParameters Define the JSON representation
  26254. * @returns the parsed parameters
  26255. */
  26256. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26257. }
  26258. }
  26259. declare module BABYLON {
  26260. /**
  26261. * Base class of materials working in push mode in babylon JS
  26262. * @hidden
  26263. */
  26264. export class PushMaterial extends Material {
  26265. protected _activeEffect: Effect;
  26266. protected _normalMatrix: Matrix;
  26267. /**
  26268. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26269. * This means that the material can keep using a previous shader while a new one is being compiled.
  26270. * This is mostly used when shader parallel compilation is supported (true by default)
  26271. */
  26272. allowShaderHotSwapping: boolean;
  26273. constructor(name: string, scene: Scene);
  26274. getEffect(): Effect;
  26275. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26276. /**
  26277. * Binds the given world matrix to the active effect
  26278. *
  26279. * @param world the matrix to bind
  26280. */
  26281. bindOnlyWorldMatrix(world: Matrix): void;
  26282. /**
  26283. * Binds the given normal matrix to the active effect
  26284. *
  26285. * @param normalMatrix the matrix to bind
  26286. */
  26287. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26288. bind(world: Matrix, mesh?: Mesh): void;
  26289. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26290. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26291. }
  26292. }
  26293. declare module BABYLON {
  26294. /**
  26295. * This groups all the flags used to control the materials channel.
  26296. */
  26297. export class MaterialFlags {
  26298. private static _DiffuseTextureEnabled;
  26299. /**
  26300. * Are diffuse textures enabled in the application.
  26301. */
  26302. static get DiffuseTextureEnabled(): boolean;
  26303. static set DiffuseTextureEnabled(value: boolean);
  26304. private static _AmbientTextureEnabled;
  26305. /**
  26306. * Are ambient textures enabled in the application.
  26307. */
  26308. static get AmbientTextureEnabled(): boolean;
  26309. static set AmbientTextureEnabled(value: boolean);
  26310. private static _OpacityTextureEnabled;
  26311. /**
  26312. * Are opacity textures enabled in the application.
  26313. */
  26314. static get OpacityTextureEnabled(): boolean;
  26315. static set OpacityTextureEnabled(value: boolean);
  26316. private static _ReflectionTextureEnabled;
  26317. /**
  26318. * Are reflection textures enabled in the application.
  26319. */
  26320. static get ReflectionTextureEnabled(): boolean;
  26321. static set ReflectionTextureEnabled(value: boolean);
  26322. private static _EmissiveTextureEnabled;
  26323. /**
  26324. * Are emissive textures enabled in the application.
  26325. */
  26326. static get EmissiveTextureEnabled(): boolean;
  26327. static set EmissiveTextureEnabled(value: boolean);
  26328. private static _SpecularTextureEnabled;
  26329. /**
  26330. * Are specular textures enabled in the application.
  26331. */
  26332. static get SpecularTextureEnabled(): boolean;
  26333. static set SpecularTextureEnabled(value: boolean);
  26334. private static _BumpTextureEnabled;
  26335. /**
  26336. * Are bump textures enabled in the application.
  26337. */
  26338. static get BumpTextureEnabled(): boolean;
  26339. static set BumpTextureEnabled(value: boolean);
  26340. private static _LightmapTextureEnabled;
  26341. /**
  26342. * Are lightmap textures enabled in the application.
  26343. */
  26344. static get LightmapTextureEnabled(): boolean;
  26345. static set LightmapTextureEnabled(value: boolean);
  26346. private static _RefractionTextureEnabled;
  26347. /**
  26348. * Are refraction textures enabled in the application.
  26349. */
  26350. static get RefractionTextureEnabled(): boolean;
  26351. static set RefractionTextureEnabled(value: boolean);
  26352. private static _ColorGradingTextureEnabled;
  26353. /**
  26354. * Are color grading textures enabled in the application.
  26355. */
  26356. static get ColorGradingTextureEnabled(): boolean;
  26357. static set ColorGradingTextureEnabled(value: boolean);
  26358. private static _FresnelEnabled;
  26359. /**
  26360. * Are fresnels enabled in the application.
  26361. */
  26362. static get FresnelEnabled(): boolean;
  26363. static set FresnelEnabled(value: boolean);
  26364. private static _ClearCoatTextureEnabled;
  26365. /**
  26366. * Are clear coat textures enabled in the application.
  26367. */
  26368. static get ClearCoatTextureEnabled(): boolean;
  26369. static set ClearCoatTextureEnabled(value: boolean);
  26370. private static _ClearCoatBumpTextureEnabled;
  26371. /**
  26372. * Are clear coat bump textures enabled in the application.
  26373. */
  26374. static get ClearCoatBumpTextureEnabled(): boolean;
  26375. static set ClearCoatBumpTextureEnabled(value: boolean);
  26376. private static _ClearCoatTintTextureEnabled;
  26377. /**
  26378. * Are clear coat tint textures enabled in the application.
  26379. */
  26380. static get ClearCoatTintTextureEnabled(): boolean;
  26381. static set ClearCoatTintTextureEnabled(value: boolean);
  26382. private static _SheenTextureEnabled;
  26383. /**
  26384. * Are sheen textures enabled in the application.
  26385. */
  26386. static get SheenTextureEnabled(): boolean;
  26387. static set SheenTextureEnabled(value: boolean);
  26388. private static _AnisotropicTextureEnabled;
  26389. /**
  26390. * Are anisotropic textures enabled in the application.
  26391. */
  26392. static get AnisotropicTextureEnabled(): boolean;
  26393. static set AnisotropicTextureEnabled(value: boolean);
  26394. private static _ThicknessTextureEnabled;
  26395. /**
  26396. * Are thickness textures enabled in the application.
  26397. */
  26398. static get ThicknessTextureEnabled(): boolean;
  26399. static set ThicknessTextureEnabled(value: boolean);
  26400. }
  26401. }
  26402. declare module BABYLON {
  26403. /** @hidden */
  26404. export var defaultFragmentDeclaration: {
  26405. name: string;
  26406. shader: string;
  26407. };
  26408. }
  26409. declare module BABYLON {
  26410. /** @hidden */
  26411. export var defaultUboDeclaration: {
  26412. name: string;
  26413. shader: string;
  26414. };
  26415. }
  26416. declare module BABYLON {
  26417. /** @hidden */
  26418. export var lightFragmentDeclaration: {
  26419. name: string;
  26420. shader: string;
  26421. };
  26422. }
  26423. declare module BABYLON {
  26424. /** @hidden */
  26425. export var lightUboDeclaration: {
  26426. name: string;
  26427. shader: string;
  26428. };
  26429. }
  26430. declare module BABYLON {
  26431. /** @hidden */
  26432. export var lightsFragmentFunctions: {
  26433. name: string;
  26434. shader: string;
  26435. };
  26436. }
  26437. declare module BABYLON {
  26438. /** @hidden */
  26439. export var shadowsFragmentFunctions: {
  26440. name: string;
  26441. shader: string;
  26442. };
  26443. }
  26444. declare module BABYLON {
  26445. /** @hidden */
  26446. export var fresnelFunction: {
  26447. name: string;
  26448. shader: string;
  26449. };
  26450. }
  26451. declare module BABYLON {
  26452. /** @hidden */
  26453. export var reflectionFunction: {
  26454. name: string;
  26455. shader: string;
  26456. };
  26457. }
  26458. declare module BABYLON {
  26459. /** @hidden */
  26460. export var bumpFragmentFunctions: {
  26461. name: string;
  26462. shader: string;
  26463. };
  26464. }
  26465. declare module BABYLON {
  26466. /** @hidden */
  26467. export var logDepthDeclaration: {
  26468. name: string;
  26469. shader: string;
  26470. };
  26471. }
  26472. declare module BABYLON {
  26473. /** @hidden */
  26474. export var bumpFragment: {
  26475. name: string;
  26476. shader: string;
  26477. };
  26478. }
  26479. declare module BABYLON {
  26480. /** @hidden */
  26481. export var depthPrePass: {
  26482. name: string;
  26483. shader: string;
  26484. };
  26485. }
  26486. declare module BABYLON {
  26487. /** @hidden */
  26488. export var lightFragment: {
  26489. name: string;
  26490. shader: string;
  26491. };
  26492. }
  26493. declare module BABYLON {
  26494. /** @hidden */
  26495. export var logDepthFragment: {
  26496. name: string;
  26497. shader: string;
  26498. };
  26499. }
  26500. declare module BABYLON {
  26501. /** @hidden */
  26502. export var defaultPixelShader: {
  26503. name: string;
  26504. shader: string;
  26505. };
  26506. }
  26507. declare module BABYLON {
  26508. /** @hidden */
  26509. export var defaultVertexDeclaration: {
  26510. name: string;
  26511. shader: string;
  26512. };
  26513. }
  26514. declare module BABYLON {
  26515. /** @hidden */
  26516. export var bumpVertexDeclaration: {
  26517. name: string;
  26518. shader: string;
  26519. };
  26520. }
  26521. declare module BABYLON {
  26522. /** @hidden */
  26523. export var bumpVertex: {
  26524. name: string;
  26525. shader: string;
  26526. };
  26527. }
  26528. declare module BABYLON {
  26529. /** @hidden */
  26530. export var fogVertex: {
  26531. name: string;
  26532. shader: string;
  26533. };
  26534. }
  26535. declare module BABYLON {
  26536. /** @hidden */
  26537. export var shadowsVertex: {
  26538. name: string;
  26539. shader: string;
  26540. };
  26541. }
  26542. declare module BABYLON {
  26543. /** @hidden */
  26544. export var pointCloudVertex: {
  26545. name: string;
  26546. shader: string;
  26547. };
  26548. }
  26549. declare module BABYLON {
  26550. /** @hidden */
  26551. export var logDepthVertex: {
  26552. name: string;
  26553. shader: string;
  26554. };
  26555. }
  26556. declare module BABYLON {
  26557. /** @hidden */
  26558. export var defaultVertexShader: {
  26559. name: string;
  26560. shader: string;
  26561. };
  26562. }
  26563. declare module BABYLON {
  26564. /** @hidden */
  26565. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26566. MAINUV1: boolean;
  26567. MAINUV2: boolean;
  26568. DIFFUSE: boolean;
  26569. DIFFUSEDIRECTUV: number;
  26570. AMBIENT: boolean;
  26571. AMBIENTDIRECTUV: number;
  26572. OPACITY: boolean;
  26573. OPACITYDIRECTUV: number;
  26574. OPACITYRGB: boolean;
  26575. REFLECTION: boolean;
  26576. EMISSIVE: boolean;
  26577. EMISSIVEDIRECTUV: number;
  26578. SPECULAR: boolean;
  26579. SPECULARDIRECTUV: number;
  26580. BUMP: boolean;
  26581. BUMPDIRECTUV: number;
  26582. PARALLAX: boolean;
  26583. PARALLAXOCCLUSION: boolean;
  26584. SPECULAROVERALPHA: boolean;
  26585. CLIPPLANE: boolean;
  26586. CLIPPLANE2: boolean;
  26587. CLIPPLANE3: boolean;
  26588. CLIPPLANE4: boolean;
  26589. CLIPPLANE5: boolean;
  26590. CLIPPLANE6: boolean;
  26591. ALPHATEST: boolean;
  26592. DEPTHPREPASS: boolean;
  26593. ALPHAFROMDIFFUSE: boolean;
  26594. POINTSIZE: boolean;
  26595. FOG: boolean;
  26596. SPECULARTERM: boolean;
  26597. DIFFUSEFRESNEL: boolean;
  26598. OPACITYFRESNEL: boolean;
  26599. REFLECTIONFRESNEL: boolean;
  26600. REFRACTIONFRESNEL: boolean;
  26601. EMISSIVEFRESNEL: boolean;
  26602. FRESNEL: boolean;
  26603. NORMAL: boolean;
  26604. UV1: boolean;
  26605. UV2: boolean;
  26606. VERTEXCOLOR: boolean;
  26607. VERTEXALPHA: boolean;
  26608. NUM_BONE_INFLUENCERS: number;
  26609. BonesPerMesh: number;
  26610. BONETEXTURE: boolean;
  26611. INSTANCES: boolean;
  26612. GLOSSINESS: boolean;
  26613. ROUGHNESS: boolean;
  26614. EMISSIVEASILLUMINATION: boolean;
  26615. LINKEMISSIVEWITHDIFFUSE: boolean;
  26616. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26617. LIGHTMAP: boolean;
  26618. LIGHTMAPDIRECTUV: number;
  26619. OBJECTSPACE_NORMALMAP: boolean;
  26620. USELIGHTMAPASSHADOWMAP: boolean;
  26621. REFLECTIONMAP_3D: boolean;
  26622. REFLECTIONMAP_SPHERICAL: boolean;
  26623. REFLECTIONMAP_PLANAR: boolean;
  26624. REFLECTIONMAP_CUBIC: boolean;
  26625. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26626. REFLECTIONMAP_PROJECTION: boolean;
  26627. REFLECTIONMAP_SKYBOX: boolean;
  26628. REFLECTIONMAP_EXPLICIT: boolean;
  26629. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26630. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26631. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26632. INVERTCUBICMAP: boolean;
  26633. LOGARITHMICDEPTH: boolean;
  26634. REFRACTION: boolean;
  26635. REFRACTIONMAP_3D: boolean;
  26636. REFLECTIONOVERALPHA: boolean;
  26637. TWOSIDEDLIGHTING: boolean;
  26638. SHADOWFLOAT: boolean;
  26639. MORPHTARGETS: boolean;
  26640. MORPHTARGETS_NORMAL: boolean;
  26641. MORPHTARGETS_TANGENT: boolean;
  26642. MORPHTARGETS_UV: boolean;
  26643. NUM_MORPH_INFLUENCERS: number;
  26644. NONUNIFORMSCALING: boolean;
  26645. PREMULTIPLYALPHA: boolean;
  26646. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26647. ALPHABLEND: boolean;
  26648. IMAGEPROCESSING: boolean;
  26649. VIGNETTE: boolean;
  26650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26651. VIGNETTEBLENDMODEOPAQUE: boolean;
  26652. TONEMAPPING: boolean;
  26653. TONEMAPPING_ACES: boolean;
  26654. CONTRAST: boolean;
  26655. COLORCURVES: boolean;
  26656. COLORGRADING: boolean;
  26657. COLORGRADING3D: boolean;
  26658. SAMPLER3DGREENDEPTH: boolean;
  26659. SAMPLER3DBGRMAP: boolean;
  26660. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26661. MULTIVIEW: boolean;
  26662. /**
  26663. * If the reflection texture on this material is in linear color space
  26664. * @hidden
  26665. */
  26666. IS_REFLECTION_LINEAR: boolean;
  26667. /**
  26668. * If the refraction texture on this material is in linear color space
  26669. * @hidden
  26670. */
  26671. IS_REFRACTION_LINEAR: boolean;
  26672. EXPOSURE: boolean;
  26673. constructor();
  26674. setReflectionMode(modeToEnable: string): void;
  26675. }
  26676. /**
  26677. * This is the default material used in Babylon. It is the best trade off between quality
  26678. * and performances.
  26679. * @see http://doc.babylonjs.com/babylon101/materials
  26680. */
  26681. export class StandardMaterial extends PushMaterial {
  26682. private _diffuseTexture;
  26683. /**
  26684. * The basic texture of the material as viewed under a light.
  26685. */
  26686. diffuseTexture: Nullable<BaseTexture>;
  26687. private _ambientTexture;
  26688. /**
  26689. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26690. */
  26691. ambientTexture: Nullable<BaseTexture>;
  26692. private _opacityTexture;
  26693. /**
  26694. * Define the transparency of the material from a texture.
  26695. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26696. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26697. */
  26698. opacityTexture: Nullable<BaseTexture>;
  26699. private _reflectionTexture;
  26700. /**
  26701. * Define the texture used to display the reflection.
  26702. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26703. */
  26704. reflectionTexture: Nullable<BaseTexture>;
  26705. private _emissiveTexture;
  26706. /**
  26707. * Define texture of the material as if self lit.
  26708. * This will be mixed in the final result even in the absence of light.
  26709. */
  26710. emissiveTexture: Nullable<BaseTexture>;
  26711. private _specularTexture;
  26712. /**
  26713. * Define how the color and intensity of the highlight given by the light in the material.
  26714. */
  26715. specularTexture: Nullable<BaseTexture>;
  26716. private _bumpTexture;
  26717. /**
  26718. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26719. * 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.
  26720. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26721. */
  26722. bumpTexture: Nullable<BaseTexture>;
  26723. private _lightmapTexture;
  26724. /**
  26725. * Complex lighting can be computationally expensive to compute at runtime.
  26726. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26727. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26728. */
  26729. lightmapTexture: Nullable<BaseTexture>;
  26730. private _refractionTexture;
  26731. /**
  26732. * Define the texture used to display the refraction.
  26733. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26734. */
  26735. refractionTexture: Nullable<BaseTexture>;
  26736. /**
  26737. * The color of the material lit by the environmental background lighting.
  26738. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26739. */
  26740. ambientColor: Color3;
  26741. /**
  26742. * The basic color of the material as viewed under a light.
  26743. */
  26744. diffuseColor: Color3;
  26745. /**
  26746. * Define how the color and intensity of the highlight given by the light in the material.
  26747. */
  26748. specularColor: Color3;
  26749. /**
  26750. * Define the color of the material as if self lit.
  26751. * This will be mixed in the final result even in the absence of light.
  26752. */
  26753. emissiveColor: Color3;
  26754. /**
  26755. * Defines how sharp are the highlights in the material.
  26756. * The bigger the value the sharper giving a more glossy feeling to the result.
  26757. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26758. */
  26759. specularPower: number;
  26760. private _useAlphaFromDiffuseTexture;
  26761. /**
  26762. * Does the transparency come from the diffuse texture alpha channel.
  26763. */
  26764. useAlphaFromDiffuseTexture: boolean;
  26765. private _useEmissiveAsIllumination;
  26766. /**
  26767. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26768. */
  26769. useEmissiveAsIllumination: boolean;
  26770. private _linkEmissiveWithDiffuse;
  26771. /**
  26772. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26773. * the emissive level when the final color is close to one.
  26774. */
  26775. linkEmissiveWithDiffuse: boolean;
  26776. private _useSpecularOverAlpha;
  26777. /**
  26778. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26779. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26780. */
  26781. useSpecularOverAlpha: boolean;
  26782. private _useReflectionOverAlpha;
  26783. /**
  26784. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26785. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26786. */
  26787. useReflectionOverAlpha: boolean;
  26788. private _disableLighting;
  26789. /**
  26790. * Does lights from the scene impacts this material.
  26791. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26792. */
  26793. disableLighting: boolean;
  26794. private _useObjectSpaceNormalMap;
  26795. /**
  26796. * Allows using an object space normal map (instead of tangent space).
  26797. */
  26798. useObjectSpaceNormalMap: boolean;
  26799. private _useParallax;
  26800. /**
  26801. * Is parallax enabled or not.
  26802. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26803. */
  26804. useParallax: boolean;
  26805. private _useParallaxOcclusion;
  26806. /**
  26807. * Is parallax occlusion enabled or not.
  26808. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26809. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26810. */
  26811. useParallaxOcclusion: boolean;
  26812. /**
  26813. * 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.
  26814. */
  26815. parallaxScaleBias: number;
  26816. private _roughness;
  26817. /**
  26818. * Helps to define how blurry the reflections should appears in the material.
  26819. */
  26820. roughness: number;
  26821. /**
  26822. * In case of refraction, define the value of the index of refraction.
  26823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26824. */
  26825. indexOfRefraction: number;
  26826. /**
  26827. * Invert the refraction texture alongside the y axis.
  26828. * It can be useful with procedural textures or probe for instance.
  26829. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26830. */
  26831. invertRefractionY: boolean;
  26832. /**
  26833. * Defines the alpha limits in alpha test mode.
  26834. */
  26835. alphaCutOff: number;
  26836. private _useLightmapAsShadowmap;
  26837. /**
  26838. * In case of light mapping, define whether the map contains light or shadow informations.
  26839. */
  26840. useLightmapAsShadowmap: boolean;
  26841. private _diffuseFresnelParameters;
  26842. /**
  26843. * Define the diffuse fresnel parameters of the material.
  26844. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26845. */
  26846. diffuseFresnelParameters: FresnelParameters;
  26847. private _opacityFresnelParameters;
  26848. /**
  26849. * Define the opacity fresnel parameters of the material.
  26850. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26851. */
  26852. opacityFresnelParameters: FresnelParameters;
  26853. private _reflectionFresnelParameters;
  26854. /**
  26855. * Define the reflection fresnel parameters of the material.
  26856. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26857. */
  26858. reflectionFresnelParameters: FresnelParameters;
  26859. private _refractionFresnelParameters;
  26860. /**
  26861. * Define the refraction fresnel parameters of the material.
  26862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26863. */
  26864. refractionFresnelParameters: FresnelParameters;
  26865. private _emissiveFresnelParameters;
  26866. /**
  26867. * Define the emissive fresnel parameters of the material.
  26868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26869. */
  26870. emissiveFresnelParameters: FresnelParameters;
  26871. private _useReflectionFresnelFromSpecular;
  26872. /**
  26873. * If true automatically deducts the fresnels values from the material specularity.
  26874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26875. */
  26876. useReflectionFresnelFromSpecular: boolean;
  26877. private _useGlossinessFromSpecularMapAlpha;
  26878. /**
  26879. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26880. */
  26881. useGlossinessFromSpecularMapAlpha: boolean;
  26882. private _maxSimultaneousLights;
  26883. /**
  26884. * Defines the maximum number of lights that can be used in the material
  26885. */
  26886. maxSimultaneousLights: number;
  26887. private _invertNormalMapX;
  26888. /**
  26889. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26890. */
  26891. invertNormalMapX: boolean;
  26892. private _invertNormalMapY;
  26893. /**
  26894. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26895. */
  26896. invertNormalMapY: boolean;
  26897. private _twoSidedLighting;
  26898. /**
  26899. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26900. */
  26901. twoSidedLighting: boolean;
  26902. /**
  26903. * Default configuration related to image processing available in the standard Material.
  26904. */
  26905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26906. /**
  26907. * Gets the image processing configuration used either in this material.
  26908. */
  26909. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26910. /**
  26911. * Sets the Default image processing configuration used either in the this material.
  26912. *
  26913. * If sets to null, the scene one is in use.
  26914. */
  26915. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26916. /**
  26917. * Keep track of the image processing observer to allow dispose and replace.
  26918. */
  26919. private _imageProcessingObserver;
  26920. /**
  26921. * Attaches a new image processing configuration to the Standard Material.
  26922. * @param configuration
  26923. */
  26924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26925. /**
  26926. * Gets wether the color curves effect is enabled.
  26927. */
  26928. get cameraColorCurvesEnabled(): boolean;
  26929. /**
  26930. * Sets wether the color curves effect is enabled.
  26931. */
  26932. set cameraColorCurvesEnabled(value: boolean);
  26933. /**
  26934. * Gets wether the color grading effect is enabled.
  26935. */
  26936. get cameraColorGradingEnabled(): boolean;
  26937. /**
  26938. * Gets wether the color grading effect is enabled.
  26939. */
  26940. set cameraColorGradingEnabled(value: boolean);
  26941. /**
  26942. * Gets wether tonemapping is enabled or not.
  26943. */
  26944. get cameraToneMappingEnabled(): boolean;
  26945. /**
  26946. * Sets wether tonemapping is enabled or not
  26947. */
  26948. set cameraToneMappingEnabled(value: boolean);
  26949. /**
  26950. * The camera exposure used on this material.
  26951. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26952. * This corresponds to a photographic exposure.
  26953. */
  26954. get cameraExposure(): number;
  26955. /**
  26956. * The camera exposure used on this material.
  26957. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26958. * This corresponds to a photographic exposure.
  26959. */
  26960. set cameraExposure(value: number);
  26961. /**
  26962. * Gets The camera contrast used on this material.
  26963. */
  26964. get cameraContrast(): number;
  26965. /**
  26966. * Sets The camera contrast used on this material.
  26967. */
  26968. set cameraContrast(value: number);
  26969. /**
  26970. * Gets the Color Grading 2D Lookup Texture.
  26971. */
  26972. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26973. /**
  26974. * Sets the Color Grading 2D Lookup Texture.
  26975. */
  26976. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26977. /**
  26978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26980. * 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;
  26981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26982. */
  26983. get cameraColorCurves(): Nullable<ColorCurves>;
  26984. /**
  26985. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26986. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26987. * 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;
  26988. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26989. */
  26990. set cameraColorCurves(value: Nullable<ColorCurves>);
  26991. /**
  26992. * Custom callback helping to override the default shader used in the material.
  26993. */
  26994. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  26995. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26996. protected _worldViewProjectionMatrix: Matrix;
  26997. protected _globalAmbientColor: Color3;
  26998. protected _useLogarithmicDepth: boolean;
  26999. protected _rebuildInParallel: boolean;
  27000. /**
  27001. * Instantiates a new standard material.
  27002. * This is the default material used in Babylon. It is the best trade off between quality
  27003. * and performances.
  27004. * @see http://doc.babylonjs.com/babylon101/materials
  27005. * @param name Define the name of the material in the scene
  27006. * @param scene Define the scene the material belong to
  27007. */
  27008. constructor(name: string, scene: Scene);
  27009. /**
  27010. * Gets a boolean indicating that current material needs to register RTT
  27011. */
  27012. get hasRenderTargetTextures(): boolean;
  27013. /**
  27014. * Gets the current class name of the material e.g. "StandardMaterial"
  27015. * Mainly use in serialization.
  27016. * @returns the class name
  27017. */
  27018. getClassName(): string;
  27019. /**
  27020. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27021. * You can try switching to logarithmic depth.
  27022. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27023. */
  27024. get useLogarithmicDepth(): boolean;
  27025. set useLogarithmicDepth(value: boolean);
  27026. /**
  27027. * Specifies if the material will require alpha blending
  27028. * @returns a boolean specifying if alpha blending is needed
  27029. */
  27030. needAlphaBlending(): boolean;
  27031. /**
  27032. * Specifies if this material should be rendered in alpha test mode
  27033. * @returns a boolean specifying if an alpha test is needed.
  27034. */
  27035. needAlphaTesting(): boolean;
  27036. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27037. /**
  27038. * Get the texture used for alpha test purpose.
  27039. * @returns the diffuse texture in case of the standard material.
  27040. */
  27041. getAlphaTestTexture(): Nullable<BaseTexture>;
  27042. /**
  27043. * Get if the submesh is ready to be used and all its information available.
  27044. * Child classes can use it to update shaders
  27045. * @param mesh defines the mesh to check
  27046. * @param subMesh defines which submesh to check
  27047. * @param useInstances specifies that instances should be used
  27048. * @returns a boolean indicating that the submesh is ready or not
  27049. */
  27050. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27051. /**
  27052. * Builds the material UBO layouts.
  27053. * Used internally during the effect preparation.
  27054. */
  27055. buildUniformLayout(): void;
  27056. /**
  27057. * Unbinds the material from the mesh
  27058. */
  27059. unbind(): void;
  27060. /**
  27061. * Binds the submesh to this material by preparing the effect and shader to draw
  27062. * @param world defines the world transformation matrix
  27063. * @param mesh defines the mesh containing the submesh
  27064. * @param subMesh defines the submesh to bind the material to
  27065. */
  27066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27067. /**
  27068. * Get the list of animatables in the material.
  27069. * @returns the list of animatables object used in the material
  27070. */
  27071. getAnimatables(): IAnimatable[];
  27072. /**
  27073. * Gets the active textures from the material
  27074. * @returns an array of textures
  27075. */
  27076. getActiveTextures(): BaseTexture[];
  27077. /**
  27078. * Specifies if the material uses a texture
  27079. * @param texture defines the texture to check against the material
  27080. * @returns a boolean specifying if the material uses the texture
  27081. */
  27082. hasTexture(texture: BaseTexture): boolean;
  27083. /**
  27084. * Disposes the material
  27085. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27086. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27087. */
  27088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27089. /**
  27090. * Makes a duplicate of the material, and gives it a new name
  27091. * @param name defines the new name for the duplicated material
  27092. * @returns the cloned material
  27093. */
  27094. clone(name: string): StandardMaterial;
  27095. /**
  27096. * Serializes this material in a JSON representation
  27097. * @returns the serialized material object
  27098. */
  27099. serialize(): any;
  27100. /**
  27101. * Creates a standard material from parsed material data
  27102. * @param source defines the JSON representation of the material
  27103. * @param scene defines the hosting scene
  27104. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27105. * @returns a new standard material
  27106. */
  27107. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27108. /**
  27109. * Are diffuse textures enabled in the application.
  27110. */
  27111. static get DiffuseTextureEnabled(): boolean;
  27112. static set DiffuseTextureEnabled(value: boolean);
  27113. /**
  27114. * Are ambient textures enabled in the application.
  27115. */
  27116. static get AmbientTextureEnabled(): boolean;
  27117. static set AmbientTextureEnabled(value: boolean);
  27118. /**
  27119. * Are opacity textures enabled in the application.
  27120. */
  27121. static get OpacityTextureEnabled(): boolean;
  27122. static set OpacityTextureEnabled(value: boolean);
  27123. /**
  27124. * Are reflection textures enabled in the application.
  27125. */
  27126. static get ReflectionTextureEnabled(): boolean;
  27127. static set ReflectionTextureEnabled(value: boolean);
  27128. /**
  27129. * Are emissive textures enabled in the application.
  27130. */
  27131. static get EmissiveTextureEnabled(): boolean;
  27132. static set EmissiveTextureEnabled(value: boolean);
  27133. /**
  27134. * Are specular textures enabled in the application.
  27135. */
  27136. static get SpecularTextureEnabled(): boolean;
  27137. static set SpecularTextureEnabled(value: boolean);
  27138. /**
  27139. * Are bump textures enabled in the application.
  27140. */
  27141. static get BumpTextureEnabled(): boolean;
  27142. static set BumpTextureEnabled(value: boolean);
  27143. /**
  27144. * Are lightmap textures enabled in the application.
  27145. */
  27146. static get LightmapTextureEnabled(): boolean;
  27147. static set LightmapTextureEnabled(value: boolean);
  27148. /**
  27149. * Are refraction textures enabled in the application.
  27150. */
  27151. static get RefractionTextureEnabled(): boolean;
  27152. static set RefractionTextureEnabled(value: boolean);
  27153. /**
  27154. * Are color grading textures enabled in the application.
  27155. */
  27156. static get ColorGradingTextureEnabled(): boolean;
  27157. static set ColorGradingTextureEnabled(value: boolean);
  27158. /**
  27159. * Are fresnels enabled in the application.
  27160. */
  27161. static get FresnelEnabled(): boolean;
  27162. static set FresnelEnabled(value: boolean);
  27163. }
  27164. }
  27165. declare module BABYLON {
  27166. /**
  27167. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27168. *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.
  27169. * The SPS is also a particle system. It provides some methods to manage the particles.
  27170. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27171. *
  27172. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27173. */
  27174. export class SolidParticleSystem implements IDisposable {
  27175. /**
  27176. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27177. * Example : var p = SPS.particles[i];
  27178. */
  27179. particles: SolidParticle[];
  27180. /**
  27181. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27182. */
  27183. nbParticles: number;
  27184. /**
  27185. * If the particles must ever face the camera (default false). Useful for planar particles.
  27186. */
  27187. billboard: boolean;
  27188. /**
  27189. * Recompute normals when adding a shape
  27190. */
  27191. recomputeNormals: boolean;
  27192. /**
  27193. * This a counter ofr your own usage. It's not set by any SPS functions.
  27194. */
  27195. counter: number;
  27196. /**
  27197. * The SPS name. This name is also given to the underlying mesh.
  27198. */
  27199. name: string;
  27200. /**
  27201. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27202. */
  27203. mesh: Mesh;
  27204. /**
  27205. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27206. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27207. */
  27208. vars: any;
  27209. /**
  27210. * This array is populated when the SPS is set as 'pickable'.
  27211. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27212. * Each element of this array is an object `{idx: int, faceId: int}`.
  27213. * `idx` is the picked particle index in the `SPS.particles` array
  27214. * `faceId` is the picked face index counted within this particle.
  27215. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27216. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27217. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27218. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27219. */
  27220. pickedParticles: {
  27221. idx: number;
  27222. faceId: number;
  27223. }[];
  27224. /**
  27225. * This array is populated when the SPS is set as 'pickable'
  27226. * Each key of this array is a submesh index.
  27227. * Each element of this array is a second array defined like this :
  27228. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27229. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27230. * `idx` is the picked particle index in the `SPS.particles` array
  27231. * `faceId` is the picked face index counted within this particle.
  27232. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27233. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27234. */
  27235. pickedBySubMesh: {
  27236. idx: number;
  27237. faceId: number;
  27238. }[][];
  27239. /**
  27240. * This array is populated when `enableDepthSort` is set to true.
  27241. * Each element of this array is an instance of the class DepthSortedParticle.
  27242. */
  27243. depthSortedParticles: DepthSortedParticle[];
  27244. /**
  27245. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27246. * @hidden
  27247. */
  27248. _bSphereOnly: boolean;
  27249. /**
  27250. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27251. * @hidden
  27252. */
  27253. _bSphereRadiusFactor: number;
  27254. private _scene;
  27255. private _positions;
  27256. private _indices;
  27257. private _normals;
  27258. private _colors;
  27259. private _uvs;
  27260. private _indices32;
  27261. private _positions32;
  27262. private _normals32;
  27263. private _fixedNormal32;
  27264. private _colors32;
  27265. private _uvs32;
  27266. private _index;
  27267. private _updatable;
  27268. private _pickable;
  27269. private _isVisibilityBoxLocked;
  27270. private _alwaysVisible;
  27271. private _depthSort;
  27272. private _expandable;
  27273. private _shapeCounter;
  27274. private _copy;
  27275. private _color;
  27276. private _computeParticleColor;
  27277. private _computeParticleTexture;
  27278. private _computeParticleRotation;
  27279. private _computeParticleVertex;
  27280. private _computeBoundingBox;
  27281. private _depthSortParticles;
  27282. private _camera;
  27283. private _mustUnrotateFixedNormals;
  27284. private _particlesIntersect;
  27285. private _needs32Bits;
  27286. private _isNotBuilt;
  27287. private _lastParticleId;
  27288. private _idxOfId;
  27289. private _multimaterialEnabled;
  27290. private _useModelMaterial;
  27291. private _indicesByMaterial;
  27292. private _materialIndexes;
  27293. private _depthSortFunction;
  27294. private _materialSortFunction;
  27295. private _materials;
  27296. private _multimaterial;
  27297. private _materialIndexesById;
  27298. private _defaultMaterial;
  27299. private _autoUpdateSubMeshes;
  27300. /**
  27301. * Creates a SPS (Solid Particle System) object.
  27302. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27303. * @param scene (Scene) is the scene in which the SPS is added.
  27304. * @param options defines the options of the sps e.g.
  27305. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27306. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27307. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27308. * * 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.
  27309. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27310. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27311. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27312. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27313. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27314. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27315. */
  27316. constructor(name: string, scene: Scene, options?: {
  27317. updatable?: boolean;
  27318. isPickable?: boolean;
  27319. enableDepthSort?: boolean;
  27320. particleIntersection?: boolean;
  27321. boundingSphereOnly?: boolean;
  27322. bSphereRadiusFactor?: number;
  27323. expandable?: boolean;
  27324. useModelMaterial?: boolean;
  27325. enableMultiMaterial?: boolean;
  27326. });
  27327. /**
  27328. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27329. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27330. * @returns the created mesh
  27331. */
  27332. buildMesh(): Mesh;
  27333. /**
  27334. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27335. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27336. * Thus the particles generated from `digest()` have their property `position` set yet.
  27337. * @param mesh ( Mesh ) is the mesh to be digested
  27338. * @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
  27339. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27340. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27341. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27342. * @returns the current SPS
  27343. */
  27344. digest(mesh: Mesh, options?: {
  27345. facetNb?: number;
  27346. number?: number;
  27347. delta?: number;
  27348. storage?: [];
  27349. }): SolidParticleSystem;
  27350. /**
  27351. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27352. * @hidden
  27353. */
  27354. private _unrotateFixedNormals;
  27355. /**
  27356. * Resets the temporary working copy particle
  27357. * @hidden
  27358. */
  27359. private _resetCopy;
  27360. /**
  27361. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27362. * @param p the current index in the positions array to be updated
  27363. * @param ind the current index in the indices array
  27364. * @param shape a Vector3 array, the shape geometry
  27365. * @param positions the positions array to be updated
  27366. * @param meshInd the shape indices array
  27367. * @param indices the indices array to be updated
  27368. * @param meshUV the shape uv array
  27369. * @param uvs the uv array to be updated
  27370. * @param meshCol the shape color array
  27371. * @param colors the color array to be updated
  27372. * @param meshNor the shape normals array
  27373. * @param normals the normals array to be updated
  27374. * @param idx the particle index
  27375. * @param idxInShape the particle index in its shape
  27376. * @param options the addShape() method passed options
  27377. * @model the particle model
  27378. * @hidden
  27379. */
  27380. private _meshBuilder;
  27381. /**
  27382. * Returns a shape Vector3 array from positions float array
  27383. * @param positions float array
  27384. * @returns a vector3 array
  27385. * @hidden
  27386. */
  27387. private _posToShape;
  27388. /**
  27389. * Returns a shapeUV array from a float uvs (array deep copy)
  27390. * @param uvs as a float array
  27391. * @returns a shapeUV array
  27392. * @hidden
  27393. */
  27394. private _uvsToShapeUV;
  27395. /**
  27396. * Adds a new particle object in the particles array
  27397. * @param idx particle index in particles array
  27398. * @param id particle id
  27399. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27400. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27401. * @param model particle ModelShape object
  27402. * @param shapeId model shape identifier
  27403. * @param idxInShape index of the particle in the current model
  27404. * @param bInfo model bounding info object
  27405. * @param storage target storage array, if any
  27406. * @hidden
  27407. */
  27408. private _addParticle;
  27409. /**
  27410. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27411. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27412. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27413. * @param nb (positive integer) the number of particles to be created from this model
  27414. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27415. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27416. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27417. * @returns the number of shapes in the system
  27418. */
  27419. addShape(mesh: Mesh, nb: number, options?: {
  27420. positionFunction?: any;
  27421. vertexFunction?: any;
  27422. storage?: [];
  27423. }): number;
  27424. /**
  27425. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27426. * @hidden
  27427. */
  27428. private _rebuildParticle;
  27429. /**
  27430. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27431. * @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.
  27432. * @returns the SPS.
  27433. */
  27434. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27435. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27436. * Returns an array with the removed particles.
  27437. * 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.
  27438. * The SPS can't be empty so at least one particle needs to remain in place.
  27439. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27440. * @param start index of the first particle to remove
  27441. * @param end index of the last particle to remove (included)
  27442. * @returns an array populated with the removed particles
  27443. */
  27444. removeParticles(start: number, end: number): SolidParticle[];
  27445. /**
  27446. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27447. * @param solidParticleArray an array populated with Solid Particles objects
  27448. * @returns the SPS
  27449. */
  27450. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27451. /**
  27452. * Creates a new particle and modifies the SPS mesh geometry :
  27453. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27454. * - calls _addParticle() to populate the particle array
  27455. * factorized code from addShape() and insertParticlesFromArray()
  27456. * @param idx particle index in the particles array
  27457. * @param i particle index in its shape
  27458. * @param modelShape particle ModelShape object
  27459. * @param shape shape vertex array
  27460. * @param meshInd shape indices array
  27461. * @param meshUV shape uv array
  27462. * @param meshCol shape color array
  27463. * @param meshNor shape normals array
  27464. * @param bbInfo shape bounding info
  27465. * @param storage target particle storage
  27466. * @options addShape() passed options
  27467. * @hidden
  27468. */
  27469. private _insertNewParticle;
  27470. /**
  27471. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27472. * This method calls `updateParticle()` for each particle of the SPS.
  27473. * For an animated SPS, it is usually called within the render loop.
  27474. * 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.
  27475. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27476. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27477. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27478. * @returns the SPS.
  27479. */
  27480. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27481. /**
  27482. * Disposes the SPS.
  27483. */
  27484. dispose(): void;
  27485. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27486. * idx is the particle index in the SPS
  27487. * faceId is the picked face index counted within this particle.
  27488. * Returns null if the pickInfo can't identify a picked particle.
  27489. * @param pickingInfo (PickingInfo object)
  27490. * @returns {idx: number, faceId: number} or null
  27491. */
  27492. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27493. idx: number;
  27494. faceId: number;
  27495. }>;
  27496. /**
  27497. * Returns a SolidParticle object from its identifier : particle.id
  27498. * @param id (integer) the particle Id
  27499. * @returns the searched particle or null if not found in the SPS.
  27500. */
  27501. getParticleById(id: number): Nullable<SolidParticle>;
  27502. /**
  27503. * Returns a new array populated with the particles having the passed shapeId.
  27504. * @param shapeId (integer) the shape identifier
  27505. * @returns a new solid particle array
  27506. */
  27507. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27508. /**
  27509. * Populates the passed array "ref" with the particles having the passed shapeId.
  27510. * @param shapeId the shape identifier
  27511. * @returns the SPS
  27512. * @param ref
  27513. */
  27514. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27515. /**
  27516. * Computes the required SubMeshes according the materials assigned to the particles.
  27517. * @returns the solid particle system.
  27518. * Does nothing if called before the SPS mesh is built.
  27519. */
  27520. computeSubMeshes(): SolidParticleSystem;
  27521. /**
  27522. * Sorts the solid particles by material when MultiMaterial is enabled.
  27523. * Updates the indices32 array.
  27524. * Updates the indicesByMaterial array.
  27525. * Updates the mesh indices array.
  27526. * @returns the SPS
  27527. * @hidden
  27528. */
  27529. private _sortParticlesByMaterial;
  27530. /**
  27531. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27532. * @hidden
  27533. */
  27534. private _setMaterialIndexesById;
  27535. /**
  27536. * Returns an array with unique values of Materials from the passed array
  27537. * @param array the material array to be checked and filtered
  27538. * @hidden
  27539. */
  27540. private _filterUniqueMaterialId;
  27541. /**
  27542. * Sets a new Standard Material as _defaultMaterial if not already set.
  27543. * @hidden
  27544. */
  27545. private _setDefaultMaterial;
  27546. /**
  27547. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27548. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27549. * @returns the SPS.
  27550. */
  27551. refreshVisibleSize(): SolidParticleSystem;
  27552. /**
  27553. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27554. * @param size the size (float) of the visibility box
  27555. * note : this doesn't lock the SPS mesh bounding box.
  27556. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27557. */
  27558. setVisibilityBox(size: number): void;
  27559. /**
  27560. * Gets whether the SPS as always visible or not
  27561. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27562. */
  27563. get isAlwaysVisible(): boolean;
  27564. /**
  27565. * Sets the SPS as always visible or not
  27566. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27567. */
  27568. set isAlwaysVisible(val: boolean);
  27569. /**
  27570. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27571. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27572. */
  27573. set isVisibilityBoxLocked(val: boolean);
  27574. /**
  27575. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27576. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27577. */
  27578. get isVisibilityBoxLocked(): boolean;
  27579. /**
  27580. * Tells to `setParticles()` to compute the particle rotations or not.
  27581. * Default value : true. The SPS is faster when it's set to false.
  27582. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27583. */
  27584. set computeParticleRotation(val: boolean);
  27585. /**
  27586. * Tells to `setParticles()` to compute the particle colors or not.
  27587. * Default value : true. The SPS is faster when it's set to false.
  27588. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27589. */
  27590. set computeParticleColor(val: boolean);
  27591. set computeParticleTexture(val: boolean);
  27592. /**
  27593. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27594. * Default value : false. The SPS is faster when it's set to false.
  27595. * Note : the particle custom vertex positions aren't stored values.
  27596. */
  27597. set computeParticleVertex(val: boolean);
  27598. /**
  27599. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27600. */
  27601. set computeBoundingBox(val: boolean);
  27602. /**
  27603. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27604. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27605. * Default : `true`
  27606. */
  27607. set depthSortParticles(val: boolean);
  27608. /**
  27609. * Gets if `setParticles()` computes the particle rotations or not.
  27610. * Default value : true. The SPS is faster when it's set to false.
  27611. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27612. */
  27613. get computeParticleRotation(): boolean;
  27614. /**
  27615. * Gets if `setParticles()` computes the particle colors or not.
  27616. * Default value : true. The SPS is faster when it's set to false.
  27617. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27618. */
  27619. get computeParticleColor(): boolean;
  27620. /**
  27621. * Gets if `setParticles()` computes the particle textures or not.
  27622. * Default value : true. The SPS is faster when it's set to false.
  27623. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27624. */
  27625. get computeParticleTexture(): boolean;
  27626. /**
  27627. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27628. * Default value : false. The SPS is faster when it's set to false.
  27629. * Note : the particle custom vertex positions aren't stored values.
  27630. */
  27631. get computeParticleVertex(): boolean;
  27632. /**
  27633. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27634. */
  27635. get computeBoundingBox(): boolean;
  27636. /**
  27637. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27638. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27639. * Default : `true`
  27640. */
  27641. get depthSortParticles(): boolean;
  27642. /**
  27643. * Gets if the SPS is created as expandable at construction time.
  27644. * Default : `false`
  27645. */
  27646. get expandable(): boolean;
  27647. /**
  27648. * Gets if the SPS supports the Multi Materials
  27649. */
  27650. get multimaterialEnabled(): boolean;
  27651. /**
  27652. * Gets if the SPS uses the model materials for its own multimaterial.
  27653. */
  27654. get useModelMaterial(): boolean;
  27655. /**
  27656. * The SPS used material array.
  27657. */
  27658. get materials(): Material[];
  27659. /**
  27660. * Sets the SPS MultiMaterial from the passed materials.
  27661. * Note : the passed array is internally copied and not used then by reference.
  27662. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27663. */
  27664. setMultiMaterial(materials: Material[]): void;
  27665. /**
  27666. * The SPS computed multimaterial object
  27667. */
  27668. get multimaterial(): MultiMaterial;
  27669. set multimaterial(mm: MultiMaterial);
  27670. /**
  27671. * If the subMeshes must be updated on the next call to setParticles()
  27672. */
  27673. get autoUpdateSubMeshes(): boolean;
  27674. set autoUpdateSubMeshes(val: boolean);
  27675. /**
  27676. * This function does nothing. It may be overwritten to set all the particle first values.
  27677. * The SPS doesn't call this function, you may have to call it by your own.
  27678. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27679. */
  27680. initParticles(): void;
  27681. /**
  27682. * This function does nothing. It may be overwritten to recycle a particle.
  27683. * The SPS doesn't call this function, you may have to call it by your own.
  27684. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27685. * @param particle The particle to recycle
  27686. * @returns the recycled particle
  27687. */
  27688. recycleParticle(particle: SolidParticle): SolidParticle;
  27689. /**
  27690. * Updates a particle : this function should be overwritten by the user.
  27691. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27692. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27693. * @example : just set a particle position or velocity and recycle conditions
  27694. * @param particle The particle to update
  27695. * @returns the updated particle
  27696. */
  27697. updateParticle(particle: SolidParticle): SolidParticle;
  27698. /**
  27699. * Updates a vertex of a particle : it can be overwritten by the user.
  27700. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27701. * @param particle the current particle
  27702. * @param vertex the current index of the current particle
  27703. * @param pt the index of the current vertex in the particle shape
  27704. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27705. * @example : just set a vertex particle position
  27706. * @returns the updated vertex
  27707. */
  27708. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27709. /**
  27710. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27711. * This does nothing and may be overwritten by the user.
  27712. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27713. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27714. * @param update the boolean update value actually passed to setParticles()
  27715. */
  27716. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27717. /**
  27718. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27719. * This will be passed three parameters.
  27720. * This does nothing and may be overwritten by the user.
  27721. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27722. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27723. * @param update the boolean update value actually passed to setParticles()
  27724. */
  27725. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27726. }
  27727. }
  27728. declare module BABYLON {
  27729. /**
  27730. * Represents one particle of a solid particle system.
  27731. */
  27732. export class SolidParticle {
  27733. /**
  27734. * particle global index
  27735. */
  27736. idx: number;
  27737. /**
  27738. * particle identifier
  27739. */
  27740. id: number;
  27741. /**
  27742. * The color of the particle
  27743. */
  27744. color: Nullable<Color4>;
  27745. /**
  27746. * The world space position of the particle.
  27747. */
  27748. position: Vector3;
  27749. /**
  27750. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27751. */
  27752. rotation: Vector3;
  27753. /**
  27754. * The world space rotation quaternion of the particle.
  27755. */
  27756. rotationQuaternion: Nullable<Quaternion>;
  27757. /**
  27758. * The scaling of the particle.
  27759. */
  27760. scaling: Vector3;
  27761. /**
  27762. * The uvs of the particle.
  27763. */
  27764. uvs: Vector4;
  27765. /**
  27766. * The current speed of the particle.
  27767. */
  27768. velocity: Vector3;
  27769. /**
  27770. * The pivot point in the particle local space.
  27771. */
  27772. pivot: Vector3;
  27773. /**
  27774. * Must the particle be translated from its pivot point in its local space ?
  27775. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27776. * Default : false
  27777. */
  27778. translateFromPivot: boolean;
  27779. /**
  27780. * Is the particle active or not ?
  27781. */
  27782. alive: boolean;
  27783. /**
  27784. * Is the particle visible or not ?
  27785. */
  27786. isVisible: boolean;
  27787. /**
  27788. * Index of this particle in the global "positions" array (Internal use)
  27789. * @hidden
  27790. */
  27791. _pos: number;
  27792. /**
  27793. * @hidden Index of this particle in the global "indices" array (Internal use)
  27794. */
  27795. _ind: number;
  27796. /**
  27797. * @hidden ModelShape of this particle (Internal use)
  27798. */
  27799. _model: ModelShape;
  27800. /**
  27801. * ModelShape id of this particle
  27802. */
  27803. shapeId: number;
  27804. /**
  27805. * Index of the particle in its shape id
  27806. */
  27807. idxInShape: number;
  27808. /**
  27809. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27810. */
  27811. _modelBoundingInfo: BoundingInfo;
  27812. /**
  27813. * @hidden Particle BoundingInfo object (Internal use)
  27814. */
  27815. _boundingInfo: BoundingInfo;
  27816. /**
  27817. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27818. */
  27819. _sps: SolidParticleSystem;
  27820. /**
  27821. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27822. */
  27823. _stillInvisible: boolean;
  27824. /**
  27825. * @hidden Last computed particle rotation matrix
  27826. */
  27827. _rotationMatrix: number[];
  27828. /**
  27829. * Parent particle Id, if any.
  27830. * Default null.
  27831. */
  27832. parentId: Nullable<number>;
  27833. /**
  27834. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27835. */
  27836. materialIndex: Nullable<number>;
  27837. /**
  27838. * Custom object or properties.
  27839. */
  27840. props: Nullable<any>;
  27841. /**
  27842. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27843. * The possible values are :
  27844. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27845. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27846. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27847. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27848. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27849. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27850. * */
  27851. cullingStrategy: number;
  27852. /**
  27853. * @hidden Internal global position in the SPS.
  27854. */
  27855. _globalPosition: Vector3;
  27856. /**
  27857. * Creates a Solid Particle object.
  27858. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27859. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27860. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27861. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27862. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27863. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27864. * @param shapeId (integer) is the model shape identifier in the SPS.
  27865. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27866. * @param sps defines the sps it is associated to
  27867. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27868. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27869. */
  27870. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27871. /**
  27872. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27873. * @param target the particle target
  27874. * @returns the current particle
  27875. */
  27876. copyToRef(target: SolidParticle): SolidParticle;
  27877. /**
  27878. * Legacy support, changed scale to scaling
  27879. */
  27880. get scale(): Vector3;
  27881. /**
  27882. * Legacy support, changed scale to scaling
  27883. */
  27884. set scale(scale: Vector3);
  27885. /**
  27886. * Legacy support, changed quaternion to rotationQuaternion
  27887. */
  27888. get quaternion(): Nullable<Quaternion>;
  27889. /**
  27890. * Legacy support, changed quaternion to rotationQuaternion
  27891. */
  27892. set quaternion(q: Nullable<Quaternion>);
  27893. /**
  27894. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27895. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27896. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27897. * @returns true if it intersects
  27898. */
  27899. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27900. /**
  27901. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27902. * A particle is in the frustum if its bounding box intersects the frustum
  27903. * @param frustumPlanes defines the frustum to test
  27904. * @returns true if the particle is in the frustum planes
  27905. */
  27906. isInFrustum(frustumPlanes: Plane[]): boolean;
  27907. /**
  27908. * get the rotation matrix of the particle
  27909. * @hidden
  27910. */
  27911. getRotationMatrix(m: Matrix): void;
  27912. }
  27913. /**
  27914. * Represents the shape of the model used by one particle of a solid particle system.
  27915. * SPS internal tool, don't use it manually.
  27916. */
  27917. export class ModelShape {
  27918. /**
  27919. * The shape id
  27920. * @hidden
  27921. */
  27922. shapeID: number;
  27923. /**
  27924. * flat array of model positions (internal use)
  27925. * @hidden
  27926. */
  27927. _shape: Vector3[];
  27928. /**
  27929. * flat array of model UVs (internal use)
  27930. * @hidden
  27931. */
  27932. _shapeUV: number[];
  27933. /**
  27934. * color array of the model
  27935. * @hidden
  27936. */
  27937. _shapeColors: number[];
  27938. /**
  27939. * indices array of the model
  27940. * @hidden
  27941. */
  27942. _indices: number[];
  27943. /**
  27944. * normals array of the model
  27945. * @hidden
  27946. */
  27947. _normals: number[];
  27948. /**
  27949. * length of the shape in the model indices array (internal use)
  27950. * @hidden
  27951. */
  27952. _indicesLength: number;
  27953. /**
  27954. * Custom position function (internal use)
  27955. * @hidden
  27956. */
  27957. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27958. /**
  27959. * Custom vertex function (internal use)
  27960. * @hidden
  27961. */
  27962. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27963. /**
  27964. * Model material (internal use)
  27965. * @hidden
  27966. */
  27967. _material: Nullable<Material>;
  27968. /**
  27969. * 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.
  27970. * SPS internal tool, don't use it manually.
  27971. * @hidden
  27972. */
  27973. 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>);
  27974. }
  27975. /**
  27976. * Represents a Depth Sorted Particle in the solid particle system.
  27977. * @hidden
  27978. */
  27979. export class DepthSortedParticle {
  27980. /**
  27981. * Particle index
  27982. */
  27983. idx: number;
  27984. /**
  27985. * Index of the particle in the "indices" array
  27986. */
  27987. ind: number;
  27988. /**
  27989. * Length of the particle shape in the "indices" array
  27990. */
  27991. indicesLength: number;
  27992. /**
  27993. * Squared distance from the particle to the camera
  27994. */
  27995. sqDistance: number;
  27996. /**
  27997. * Material index when used with MultiMaterials
  27998. */
  27999. materialIndex: number;
  28000. /**
  28001. * Creates a new sorted particle
  28002. * @param materialIndex
  28003. */
  28004. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28005. }
  28006. }
  28007. declare module BABYLON {
  28008. /**
  28009. * @hidden
  28010. */
  28011. export class _MeshCollisionData {
  28012. _checkCollisions: boolean;
  28013. _collisionMask: number;
  28014. _collisionGroup: number;
  28015. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28016. _collider: Nullable<Collider>;
  28017. _oldPositionForCollisions: Vector3;
  28018. _diffPositionForCollisions: Vector3;
  28019. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28020. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28021. }
  28022. }
  28023. declare module BABYLON {
  28024. /** @hidden */
  28025. class _FacetDataStorage {
  28026. facetPositions: Vector3[];
  28027. facetNormals: Vector3[];
  28028. facetPartitioning: number[][];
  28029. facetNb: number;
  28030. partitioningSubdivisions: number;
  28031. partitioningBBoxRatio: number;
  28032. facetDataEnabled: boolean;
  28033. facetParameters: any;
  28034. bbSize: Vector3;
  28035. subDiv: {
  28036. max: number;
  28037. X: number;
  28038. Y: number;
  28039. Z: number;
  28040. };
  28041. facetDepthSort: boolean;
  28042. facetDepthSortEnabled: boolean;
  28043. depthSortedIndices: IndicesArray;
  28044. depthSortedFacets: {
  28045. ind: number;
  28046. sqDistance: number;
  28047. }[];
  28048. facetDepthSortFunction: (f1: {
  28049. ind: number;
  28050. sqDistance: number;
  28051. }, f2: {
  28052. ind: number;
  28053. sqDistance: number;
  28054. }) => number;
  28055. facetDepthSortFrom: Vector3;
  28056. facetDepthSortOrigin: Vector3;
  28057. invertedMatrix: Matrix;
  28058. }
  28059. /**
  28060. * @hidden
  28061. **/
  28062. class _InternalAbstractMeshDataInfo {
  28063. _hasVertexAlpha: boolean;
  28064. _useVertexColors: boolean;
  28065. _numBoneInfluencers: number;
  28066. _applyFog: boolean;
  28067. _receiveShadows: boolean;
  28068. _facetData: _FacetDataStorage;
  28069. _visibility: number;
  28070. _skeleton: Nullable<Skeleton>;
  28071. _layerMask: number;
  28072. _computeBonesUsingShaders: boolean;
  28073. _isActive: boolean;
  28074. _onlyForInstances: boolean;
  28075. _isActiveIntermediate: boolean;
  28076. _onlyForInstancesIntermediate: boolean;
  28077. _actAsRegularMesh: boolean;
  28078. }
  28079. /**
  28080. * Class used to store all common mesh properties
  28081. */
  28082. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28083. /** No occlusion */
  28084. static OCCLUSION_TYPE_NONE: number;
  28085. /** Occlusion set to optimisitic */
  28086. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28087. /** Occlusion set to strict */
  28088. static OCCLUSION_TYPE_STRICT: number;
  28089. /** Use an accurante occlusion algorithm */
  28090. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28091. /** Use a conservative occlusion algorithm */
  28092. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28093. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28094. * Test order :
  28095. * Is the bounding sphere outside the frustum ?
  28096. * If not, are the bounding box vertices outside the frustum ?
  28097. * It not, then the cullable object is in the frustum.
  28098. */
  28099. static readonly CULLINGSTRATEGY_STANDARD: number;
  28100. /** Culling strategy : Bounding Sphere Only.
  28101. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28102. * It's also less accurate than the standard because some not visible objects can still be selected.
  28103. * Test : is the bounding sphere outside the frustum ?
  28104. * If not, then the cullable object is in the frustum.
  28105. */
  28106. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28107. /** Culling strategy : Optimistic Inclusion.
  28108. * This in an inclusion test first, then the standard exclusion test.
  28109. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28110. * 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.
  28111. * Anyway, it's as accurate as the standard strategy.
  28112. * Test :
  28113. * Is the cullable object bounding sphere center in the frustum ?
  28114. * If not, apply the default culling strategy.
  28115. */
  28116. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28117. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28118. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28119. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28120. * 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.
  28121. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28122. * Test :
  28123. * Is the cullable object bounding sphere center in the frustum ?
  28124. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28125. */
  28126. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28127. /**
  28128. * No billboard
  28129. */
  28130. static get BILLBOARDMODE_NONE(): number;
  28131. /** Billboard on X axis */
  28132. static get BILLBOARDMODE_X(): number;
  28133. /** Billboard on Y axis */
  28134. static get BILLBOARDMODE_Y(): number;
  28135. /** Billboard on Z axis */
  28136. static get BILLBOARDMODE_Z(): number;
  28137. /** Billboard on all axes */
  28138. static get BILLBOARDMODE_ALL(): number;
  28139. /** Billboard on using position instead of orientation */
  28140. static get BILLBOARDMODE_USE_POSITION(): number;
  28141. /** @hidden */
  28142. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28143. /**
  28144. * The culling strategy to use to check whether the mesh must be rendered or not.
  28145. * This value can be changed at any time and will be used on the next render mesh selection.
  28146. * The possible values are :
  28147. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28148. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28149. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28150. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28151. * Please read each static variable documentation to get details about the culling process.
  28152. * */
  28153. cullingStrategy: number;
  28154. /**
  28155. * Gets the number of facets in the mesh
  28156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28157. */
  28158. get facetNb(): number;
  28159. /**
  28160. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28162. */
  28163. get partitioningSubdivisions(): number;
  28164. set partitioningSubdivisions(nb: number);
  28165. /**
  28166. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28167. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28168. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28169. */
  28170. get partitioningBBoxRatio(): number;
  28171. set partitioningBBoxRatio(ratio: number);
  28172. /**
  28173. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28174. * Works only for updatable meshes.
  28175. * Doesn't work with multi-materials
  28176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28177. */
  28178. get mustDepthSortFacets(): boolean;
  28179. set mustDepthSortFacets(sort: boolean);
  28180. /**
  28181. * The location (Vector3) where the facet depth sort must be computed from.
  28182. * By default, the active camera position.
  28183. * Used only when facet depth sort is enabled
  28184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28185. */
  28186. get facetDepthSortFrom(): Vector3;
  28187. set facetDepthSortFrom(location: Vector3);
  28188. /**
  28189. * gets a boolean indicating if facetData is enabled
  28190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28191. */
  28192. get isFacetDataEnabled(): boolean;
  28193. /** @hidden */
  28194. _updateNonUniformScalingState(value: boolean): boolean;
  28195. /**
  28196. * An event triggered when this mesh collides with another one
  28197. */
  28198. onCollideObservable: Observable<AbstractMesh>;
  28199. /** Set a function to call when this mesh collides with another one */
  28200. set onCollide(callback: () => void);
  28201. /**
  28202. * An event triggered when the collision's position changes
  28203. */
  28204. onCollisionPositionChangeObservable: Observable<Vector3>;
  28205. /** Set a function to call when the collision's position changes */
  28206. set onCollisionPositionChange(callback: () => void);
  28207. /**
  28208. * An event triggered when material is changed
  28209. */
  28210. onMaterialChangedObservable: Observable<AbstractMesh>;
  28211. /**
  28212. * Gets or sets the orientation for POV movement & rotation
  28213. */
  28214. definedFacingForward: boolean;
  28215. /** @hidden */
  28216. _occlusionQuery: Nullable<WebGLQuery>;
  28217. /** @hidden */
  28218. _renderingGroup: Nullable<RenderingGroup>;
  28219. /**
  28220. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28221. */
  28222. get visibility(): number;
  28223. /**
  28224. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28225. */
  28226. set visibility(value: number);
  28227. /** Gets or sets the alpha index used to sort transparent meshes
  28228. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28229. */
  28230. alphaIndex: number;
  28231. /**
  28232. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28233. */
  28234. isVisible: boolean;
  28235. /**
  28236. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28237. */
  28238. isPickable: boolean;
  28239. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28240. showSubMeshesBoundingBox: boolean;
  28241. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28242. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28243. */
  28244. isBlocker: boolean;
  28245. /**
  28246. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28247. */
  28248. enablePointerMoveEvents: boolean;
  28249. /**
  28250. * Specifies the rendering group id for this mesh (0 by default)
  28251. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28252. */
  28253. renderingGroupId: number;
  28254. private _material;
  28255. /** Gets or sets current material */
  28256. get material(): Nullable<Material>;
  28257. set material(value: Nullable<Material>);
  28258. /**
  28259. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28260. * @see http://doc.babylonjs.com/babylon101/shadows
  28261. */
  28262. get receiveShadows(): boolean;
  28263. set receiveShadows(value: boolean);
  28264. /** Defines color to use when rendering outline */
  28265. outlineColor: Color3;
  28266. /** Define width to use when rendering outline */
  28267. outlineWidth: number;
  28268. /** Defines color to use when rendering overlay */
  28269. overlayColor: Color3;
  28270. /** Defines alpha to use when rendering overlay */
  28271. overlayAlpha: number;
  28272. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28273. get hasVertexAlpha(): boolean;
  28274. set hasVertexAlpha(value: boolean);
  28275. /** 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) */
  28276. get useVertexColors(): boolean;
  28277. set useVertexColors(value: boolean);
  28278. /**
  28279. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28280. */
  28281. get computeBonesUsingShaders(): boolean;
  28282. set computeBonesUsingShaders(value: boolean);
  28283. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28284. get numBoneInfluencers(): number;
  28285. set numBoneInfluencers(value: number);
  28286. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28287. get applyFog(): boolean;
  28288. set applyFog(value: boolean);
  28289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28290. useOctreeForRenderingSelection: boolean;
  28291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28292. useOctreeForPicking: boolean;
  28293. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28294. useOctreeForCollisions: boolean;
  28295. /**
  28296. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28297. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28298. */
  28299. get layerMask(): number;
  28300. set layerMask(value: number);
  28301. /**
  28302. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28303. */
  28304. alwaysSelectAsActiveMesh: boolean;
  28305. /**
  28306. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28307. */
  28308. doNotSyncBoundingInfo: boolean;
  28309. /**
  28310. * Gets or sets the current action manager
  28311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28312. */
  28313. actionManager: Nullable<AbstractActionManager>;
  28314. private _meshCollisionData;
  28315. /**
  28316. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28318. */
  28319. ellipsoid: Vector3;
  28320. /**
  28321. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28323. */
  28324. ellipsoidOffset: Vector3;
  28325. /**
  28326. * Gets or sets a collision mask used to mask collisions (default is -1).
  28327. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28328. */
  28329. get collisionMask(): number;
  28330. set collisionMask(mask: number);
  28331. /**
  28332. * Gets or sets the current collision group mask (-1 by default).
  28333. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28334. */
  28335. get collisionGroup(): number;
  28336. set collisionGroup(mask: number);
  28337. /**
  28338. * Gets or sets current surrounding meshes (null by default).
  28339. *
  28340. * By default collision detection is tested against every mesh in the scene.
  28341. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28342. * meshes will be tested for the collision.
  28343. *
  28344. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28345. */
  28346. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28347. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28348. /**
  28349. * Defines edge width used when edgesRenderer is enabled
  28350. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28351. */
  28352. edgesWidth: number;
  28353. /**
  28354. * Defines edge color used when edgesRenderer is enabled
  28355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28356. */
  28357. edgesColor: Color4;
  28358. /** @hidden */
  28359. _edgesRenderer: Nullable<IEdgesRenderer>;
  28360. /** @hidden */
  28361. _masterMesh: Nullable<AbstractMesh>;
  28362. /** @hidden */
  28363. _boundingInfo: Nullable<BoundingInfo>;
  28364. /** @hidden */
  28365. _renderId: number;
  28366. /**
  28367. * Gets or sets the list of subMeshes
  28368. * @see http://doc.babylonjs.com/how_to/multi_materials
  28369. */
  28370. subMeshes: SubMesh[];
  28371. /** @hidden */
  28372. _intersectionsInProgress: AbstractMesh[];
  28373. /** @hidden */
  28374. _unIndexed: boolean;
  28375. /** @hidden */
  28376. _lightSources: Light[];
  28377. /** Gets the list of lights affecting that mesh */
  28378. get lightSources(): Light[];
  28379. /** @hidden */
  28380. get _positions(): Nullable<Vector3[]>;
  28381. /** @hidden */
  28382. _waitingData: {
  28383. lods: Nullable<any>;
  28384. actions: Nullable<any>;
  28385. freezeWorldMatrix: Nullable<boolean>;
  28386. };
  28387. /** @hidden */
  28388. _bonesTransformMatrices: Nullable<Float32Array>;
  28389. /** @hidden */
  28390. _transformMatrixTexture: Nullable<RawTexture>;
  28391. /**
  28392. * Gets or sets a skeleton to apply skining transformations
  28393. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28394. */
  28395. set skeleton(value: Nullable<Skeleton>);
  28396. get skeleton(): Nullable<Skeleton>;
  28397. /**
  28398. * An event triggered when the mesh is rebuilt.
  28399. */
  28400. onRebuildObservable: Observable<AbstractMesh>;
  28401. /**
  28402. * Creates a new AbstractMesh
  28403. * @param name defines the name of the mesh
  28404. * @param scene defines the hosting scene
  28405. */
  28406. constructor(name: string, scene?: Nullable<Scene>);
  28407. /**
  28408. * Returns the string "AbstractMesh"
  28409. * @returns "AbstractMesh"
  28410. */
  28411. getClassName(): string;
  28412. /**
  28413. * Gets a string representation of the current mesh
  28414. * @param fullDetails defines a boolean indicating if full details must be included
  28415. * @returns a string representation of the current mesh
  28416. */
  28417. toString(fullDetails?: boolean): string;
  28418. /**
  28419. * @hidden
  28420. */
  28421. protected _getEffectiveParent(): Nullable<Node>;
  28422. /** @hidden */
  28423. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28424. /** @hidden */
  28425. _rebuild(): void;
  28426. /** @hidden */
  28427. _resyncLightSources(): void;
  28428. /** @hidden */
  28429. _resyncLightSource(light: Light): void;
  28430. /** @hidden */
  28431. _unBindEffect(): void;
  28432. /** @hidden */
  28433. _removeLightSource(light: Light, dispose: boolean): void;
  28434. private _markSubMeshesAsDirty;
  28435. /** @hidden */
  28436. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28437. /** @hidden */
  28438. _markSubMeshesAsAttributesDirty(): void;
  28439. /** @hidden */
  28440. _markSubMeshesAsMiscDirty(): void;
  28441. /**
  28442. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28443. */
  28444. get scaling(): Vector3;
  28445. set scaling(newScaling: Vector3);
  28446. /**
  28447. * Returns true if the mesh is blocked. Implemented by child classes
  28448. */
  28449. get isBlocked(): boolean;
  28450. /**
  28451. * Returns the mesh itself by default. Implemented by child classes
  28452. * @param camera defines the camera to use to pick the right LOD level
  28453. * @returns the currentAbstractMesh
  28454. */
  28455. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28456. /**
  28457. * Returns 0 by default. Implemented by child classes
  28458. * @returns an integer
  28459. */
  28460. getTotalVertices(): number;
  28461. /**
  28462. * Returns a positive integer : the total number of indices in this mesh geometry.
  28463. * @returns the numner of indices or zero if the mesh has no geometry.
  28464. */
  28465. getTotalIndices(): number;
  28466. /**
  28467. * Returns null by default. Implemented by child classes
  28468. * @returns null
  28469. */
  28470. getIndices(): Nullable<IndicesArray>;
  28471. /**
  28472. * Returns the array of the requested vertex data kind. Implemented by child classes
  28473. * @param kind defines the vertex data kind to use
  28474. * @returns null
  28475. */
  28476. getVerticesData(kind: string): Nullable<FloatArray>;
  28477. /**
  28478. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28479. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28480. * Note that a new underlying VertexBuffer object is created each call.
  28481. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28482. * @param kind defines vertex data kind:
  28483. * * VertexBuffer.PositionKind
  28484. * * VertexBuffer.UVKind
  28485. * * VertexBuffer.UV2Kind
  28486. * * VertexBuffer.UV3Kind
  28487. * * VertexBuffer.UV4Kind
  28488. * * VertexBuffer.UV5Kind
  28489. * * VertexBuffer.UV6Kind
  28490. * * VertexBuffer.ColorKind
  28491. * * VertexBuffer.MatricesIndicesKind
  28492. * * VertexBuffer.MatricesIndicesExtraKind
  28493. * * VertexBuffer.MatricesWeightsKind
  28494. * * VertexBuffer.MatricesWeightsExtraKind
  28495. * @param data defines the data source
  28496. * @param updatable defines if the data must be flagged as updatable (or static)
  28497. * @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
  28498. * @returns the current mesh
  28499. */
  28500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28501. /**
  28502. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28503. * If the mesh has no geometry, it is simply returned as it is.
  28504. * @param kind defines vertex data kind:
  28505. * * VertexBuffer.PositionKind
  28506. * * VertexBuffer.UVKind
  28507. * * VertexBuffer.UV2Kind
  28508. * * VertexBuffer.UV3Kind
  28509. * * VertexBuffer.UV4Kind
  28510. * * VertexBuffer.UV5Kind
  28511. * * VertexBuffer.UV6Kind
  28512. * * VertexBuffer.ColorKind
  28513. * * VertexBuffer.MatricesIndicesKind
  28514. * * VertexBuffer.MatricesIndicesExtraKind
  28515. * * VertexBuffer.MatricesWeightsKind
  28516. * * VertexBuffer.MatricesWeightsExtraKind
  28517. * @param data defines the data source
  28518. * @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
  28519. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28520. * @returns the current mesh
  28521. */
  28522. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28523. /**
  28524. * Sets the mesh indices,
  28525. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28526. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28527. * @param totalVertices Defines the total number of vertices
  28528. * @returns the current mesh
  28529. */
  28530. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28531. /**
  28532. * Gets a boolean indicating if specific vertex data is present
  28533. * @param kind defines the vertex data kind to use
  28534. * @returns true is data kind is present
  28535. */
  28536. isVerticesDataPresent(kind: string): boolean;
  28537. /**
  28538. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28539. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28540. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28541. * @returns a BoundingInfo
  28542. */
  28543. getBoundingInfo(): BoundingInfo;
  28544. /**
  28545. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28546. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28547. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28548. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28549. * @returns the current mesh
  28550. */
  28551. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28552. /**
  28553. * Overwrite the current bounding info
  28554. * @param boundingInfo defines the new bounding info
  28555. * @returns the current mesh
  28556. */
  28557. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28558. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28559. get useBones(): boolean;
  28560. /** @hidden */
  28561. _preActivate(): void;
  28562. /** @hidden */
  28563. _preActivateForIntermediateRendering(renderId: number): void;
  28564. /** @hidden */
  28565. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28566. /** @hidden */
  28567. _postActivate(): void;
  28568. /** @hidden */
  28569. _freeze(): void;
  28570. /** @hidden */
  28571. _unFreeze(): void;
  28572. /**
  28573. * Gets the current world matrix
  28574. * @returns a Matrix
  28575. */
  28576. getWorldMatrix(): Matrix;
  28577. /** @hidden */
  28578. _getWorldMatrixDeterminant(): number;
  28579. /**
  28580. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28581. */
  28582. get isAnInstance(): boolean;
  28583. /**
  28584. * Gets a boolean indicating if this mesh has instances
  28585. */
  28586. get hasInstances(): boolean;
  28587. /**
  28588. * Perform relative position change from the point of view of behind the front of the mesh.
  28589. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28590. * Supports definition of mesh facing forward or backward
  28591. * @param amountRight defines the distance on the right axis
  28592. * @param amountUp defines the distance on the up axis
  28593. * @param amountForward defines the distance on the forward axis
  28594. * @returns the current mesh
  28595. */
  28596. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28597. /**
  28598. * Calculate relative position change from the point of view of behind the front of the mesh.
  28599. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28600. * Supports definition of mesh facing forward or backward
  28601. * @param amountRight defines the distance on the right axis
  28602. * @param amountUp defines the distance on the up axis
  28603. * @param amountForward defines the distance on the forward axis
  28604. * @returns the new displacement vector
  28605. */
  28606. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28607. /**
  28608. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28609. * Supports definition of mesh facing forward or backward
  28610. * @param flipBack defines the flip
  28611. * @param twirlClockwise defines the twirl
  28612. * @param tiltRight defines the tilt
  28613. * @returns the current mesh
  28614. */
  28615. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28616. /**
  28617. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28618. * Supports definition of mesh facing forward or backward.
  28619. * @param flipBack defines the flip
  28620. * @param twirlClockwise defines the twirl
  28621. * @param tiltRight defines the tilt
  28622. * @returns the new rotation vector
  28623. */
  28624. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28625. /**
  28626. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28627. * This means the mesh underlying bounding box and sphere are recomputed.
  28628. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28629. * @returns the current mesh
  28630. */
  28631. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28632. /** @hidden */
  28633. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28634. /** @hidden */
  28635. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28636. /** @hidden */
  28637. _updateBoundingInfo(): AbstractMesh;
  28638. /** @hidden */
  28639. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28640. /** @hidden */
  28641. protected _afterComputeWorldMatrix(): void;
  28642. /** @hidden */
  28643. get _effectiveMesh(): AbstractMesh;
  28644. /**
  28645. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28646. * A mesh is in the frustum if its bounding box intersects the frustum
  28647. * @param frustumPlanes defines the frustum to test
  28648. * @returns true if the mesh is in the frustum planes
  28649. */
  28650. isInFrustum(frustumPlanes: Plane[]): boolean;
  28651. /**
  28652. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28653. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28654. * @param frustumPlanes defines the frustum to test
  28655. * @returns true if the mesh is completely in the frustum planes
  28656. */
  28657. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28658. /**
  28659. * True if the mesh intersects another mesh or a SolidParticle object
  28660. * @param mesh defines a target mesh or SolidParticle to test
  28661. * @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)
  28662. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28663. * @returns true if there is an intersection
  28664. */
  28665. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28666. /**
  28667. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28668. * @param point defines the point to test
  28669. * @returns true if there is an intersection
  28670. */
  28671. intersectsPoint(point: Vector3): boolean;
  28672. /**
  28673. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28675. */
  28676. get checkCollisions(): boolean;
  28677. set checkCollisions(collisionEnabled: boolean);
  28678. /**
  28679. * Gets Collider object used to compute collisions (not physics)
  28680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28681. */
  28682. get collider(): Nullable<Collider>;
  28683. /**
  28684. * Move the mesh using collision engine
  28685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28686. * @param displacement defines the requested displacement vector
  28687. * @returns the current mesh
  28688. */
  28689. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28690. private _onCollisionPositionChange;
  28691. /** @hidden */
  28692. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28693. /** @hidden */
  28694. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28695. /** @hidden */
  28696. _checkCollision(collider: Collider): AbstractMesh;
  28697. /** @hidden */
  28698. _generatePointsArray(): boolean;
  28699. /**
  28700. * Checks if the passed Ray intersects with the mesh
  28701. * @param ray defines the ray to use
  28702. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28704. * @returns the picking info
  28705. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28706. */
  28707. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28708. /**
  28709. * Clones the current mesh
  28710. * @param name defines the mesh name
  28711. * @param newParent defines the new mesh parent
  28712. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28713. * @returns the new mesh
  28714. */
  28715. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28716. /**
  28717. * Disposes all the submeshes of the current meshnp
  28718. * @returns the current mesh
  28719. */
  28720. releaseSubMeshes(): AbstractMesh;
  28721. /**
  28722. * Releases resources associated with this abstract mesh.
  28723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28725. */
  28726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28727. /**
  28728. * Adds the passed mesh as a child to the current mesh
  28729. * @param mesh defines the child mesh
  28730. * @returns the current mesh
  28731. */
  28732. addChild(mesh: AbstractMesh): AbstractMesh;
  28733. /**
  28734. * Removes the passed mesh from the current mesh children list
  28735. * @param mesh defines the child mesh
  28736. * @returns the current mesh
  28737. */
  28738. removeChild(mesh: AbstractMesh): AbstractMesh;
  28739. /** @hidden */
  28740. private _initFacetData;
  28741. /**
  28742. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28743. * This method can be called within the render loop.
  28744. * 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
  28745. * @returns the current mesh
  28746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28747. */
  28748. updateFacetData(): AbstractMesh;
  28749. /**
  28750. * Returns the facetLocalNormals array.
  28751. * The normals are expressed in the mesh local spac
  28752. * @returns an array of Vector3
  28753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28754. */
  28755. getFacetLocalNormals(): Vector3[];
  28756. /**
  28757. * Returns the facetLocalPositions array.
  28758. * The facet positions are expressed in the mesh local space
  28759. * @returns an array of Vector3
  28760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28761. */
  28762. getFacetLocalPositions(): Vector3[];
  28763. /**
  28764. * Returns the facetLocalPartioning array
  28765. * @returns an array of array of numbers
  28766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28767. */
  28768. getFacetLocalPartitioning(): number[][];
  28769. /**
  28770. * Returns the i-th facet position in the world system.
  28771. * This method allocates a new Vector3 per call
  28772. * @param i defines the facet index
  28773. * @returns a new Vector3
  28774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28775. */
  28776. getFacetPosition(i: number): Vector3;
  28777. /**
  28778. * Sets the reference Vector3 with the i-th facet position in the world system
  28779. * @param i defines the facet index
  28780. * @param ref defines the target vector
  28781. * @returns the current mesh
  28782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28783. */
  28784. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28785. /**
  28786. * Returns the i-th facet normal in the world system.
  28787. * This method allocates a new Vector3 per call
  28788. * @param i defines the facet index
  28789. * @returns a new Vector3
  28790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28791. */
  28792. getFacetNormal(i: number): Vector3;
  28793. /**
  28794. * Sets the reference Vector3 with the i-th facet normal in the world system
  28795. * @param i defines the facet index
  28796. * @param ref defines the target vector
  28797. * @returns the current mesh
  28798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28799. */
  28800. getFacetNormalToRef(i: number, ref: Vector3): this;
  28801. /**
  28802. * 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)
  28803. * @param x defines x coordinate
  28804. * @param y defines y coordinate
  28805. * @param z defines z coordinate
  28806. * @returns the array of facet indexes
  28807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28808. */
  28809. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28810. /**
  28811. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28812. * @param projected sets as the (x,y,z) world projection on the facet
  28813. * @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
  28814. * @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
  28815. * @param x defines x coordinate
  28816. * @param y defines y coordinate
  28817. * @param z defines z coordinate
  28818. * @returns the face index if found (or null instead)
  28819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28820. */
  28821. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28822. /**
  28823. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28824. * @param projected sets as the (x,y,z) local projection on the facet
  28825. * @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
  28826. * @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
  28827. * @param x defines x coordinate
  28828. * @param y defines y coordinate
  28829. * @param z defines z coordinate
  28830. * @returns the face index if found (or null instead)
  28831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28832. */
  28833. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28834. /**
  28835. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28836. * @returns the parameters
  28837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28838. */
  28839. getFacetDataParameters(): any;
  28840. /**
  28841. * Disables the feature FacetData and frees the related memory
  28842. * @returns the current mesh
  28843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28844. */
  28845. disableFacetData(): AbstractMesh;
  28846. /**
  28847. * Updates the AbstractMesh indices array
  28848. * @param indices defines the data source
  28849. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28850. * @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)
  28851. * @returns the current mesh
  28852. */
  28853. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28854. /**
  28855. * Creates new normals data for the mesh
  28856. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28857. * @returns the current mesh
  28858. */
  28859. createNormals(updatable: boolean): AbstractMesh;
  28860. /**
  28861. * Align the mesh with a normal
  28862. * @param normal defines the normal to use
  28863. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28864. * @returns the current mesh
  28865. */
  28866. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28867. /** @hidden */
  28868. _checkOcclusionQuery(): boolean;
  28869. /**
  28870. * Disables the mesh edge rendering mode
  28871. * @returns the currentAbstractMesh
  28872. */
  28873. disableEdgesRendering(): AbstractMesh;
  28874. /**
  28875. * Enables the edge rendering mode on the mesh.
  28876. * This mode makes the mesh edges visible
  28877. * @param epsilon defines the maximal distance between two angles to detect a face
  28878. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28879. * @returns the currentAbstractMesh
  28880. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28881. */
  28882. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28883. }
  28884. }
  28885. declare module BABYLON {
  28886. /**
  28887. * Interface used to define ActionEvent
  28888. */
  28889. export interface IActionEvent {
  28890. /** The mesh or sprite that triggered the action */
  28891. source: any;
  28892. /** The X mouse cursor position at the time of the event */
  28893. pointerX: number;
  28894. /** The Y mouse cursor position at the time of the event */
  28895. pointerY: number;
  28896. /** The mesh that is currently pointed at (can be null) */
  28897. meshUnderPointer: Nullable<AbstractMesh>;
  28898. /** the original (browser) event that triggered the ActionEvent */
  28899. sourceEvent?: any;
  28900. /** additional data for the event */
  28901. additionalData?: any;
  28902. }
  28903. /**
  28904. * ActionEvent is the event being sent when an action is triggered.
  28905. */
  28906. export class ActionEvent implements IActionEvent {
  28907. /** The mesh or sprite that triggered the action */
  28908. source: any;
  28909. /** The X mouse cursor position at the time of the event */
  28910. pointerX: number;
  28911. /** The Y mouse cursor position at the time of the event */
  28912. pointerY: number;
  28913. /** The mesh that is currently pointed at (can be null) */
  28914. meshUnderPointer: Nullable<AbstractMesh>;
  28915. /** the original (browser) event that triggered the ActionEvent */
  28916. sourceEvent?: any;
  28917. /** additional data for the event */
  28918. additionalData?: any;
  28919. /**
  28920. * Creates a new ActionEvent
  28921. * @param source The mesh or sprite that triggered the action
  28922. * @param pointerX The X mouse cursor position at the time of the event
  28923. * @param pointerY The Y mouse cursor position at the time of the event
  28924. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28925. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28926. * @param additionalData additional data for the event
  28927. */
  28928. constructor(
  28929. /** The mesh or sprite that triggered the action */
  28930. source: any,
  28931. /** The X mouse cursor position at the time of the event */
  28932. pointerX: number,
  28933. /** The Y mouse cursor position at the time of the event */
  28934. pointerY: number,
  28935. /** The mesh that is currently pointed at (can be null) */
  28936. meshUnderPointer: Nullable<AbstractMesh>,
  28937. /** the original (browser) event that triggered the ActionEvent */
  28938. sourceEvent?: any,
  28939. /** additional data for the event */
  28940. additionalData?: any);
  28941. /**
  28942. * Helper function to auto-create an ActionEvent from a source mesh.
  28943. * @param source The source mesh that triggered the event
  28944. * @param evt The original (browser) event
  28945. * @param additionalData additional data for the event
  28946. * @returns the new ActionEvent
  28947. */
  28948. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28949. /**
  28950. * Helper function to auto-create an ActionEvent from a source sprite
  28951. * @param source The source sprite that triggered the event
  28952. * @param scene Scene associated with the sprite
  28953. * @param evt The original (browser) event
  28954. * @param additionalData additional data for the event
  28955. * @returns the new ActionEvent
  28956. */
  28957. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28958. /**
  28959. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28960. * @param scene the scene where the event occurred
  28961. * @param evt The original (browser) event
  28962. * @returns the new ActionEvent
  28963. */
  28964. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28965. /**
  28966. * Helper function to auto-create an ActionEvent from a primitive
  28967. * @param prim defines the target primitive
  28968. * @param pointerPos defines the pointer position
  28969. * @param evt The original (browser) event
  28970. * @param additionalData additional data for the event
  28971. * @returns the new ActionEvent
  28972. */
  28973. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28974. }
  28975. }
  28976. declare module BABYLON {
  28977. /**
  28978. * Abstract class used to decouple action Manager from scene and meshes.
  28979. * Do not instantiate.
  28980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28981. */
  28982. export abstract class AbstractActionManager implements IDisposable {
  28983. /** Gets the list of active triggers */
  28984. static Triggers: {
  28985. [key: string]: number;
  28986. };
  28987. /** Gets the cursor to use when hovering items */
  28988. hoverCursor: string;
  28989. /** Gets the list of actions */
  28990. actions: IAction[];
  28991. /**
  28992. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28993. */
  28994. isRecursive: boolean;
  28995. /**
  28996. * Releases all associated resources
  28997. */
  28998. abstract dispose(): void;
  28999. /**
  29000. * Does this action manager has pointer triggers
  29001. */
  29002. abstract get hasPointerTriggers(): boolean;
  29003. /**
  29004. * Does this action manager has pick triggers
  29005. */
  29006. abstract get hasPickTriggers(): boolean;
  29007. /**
  29008. * Process a specific trigger
  29009. * @param trigger defines the trigger to process
  29010. * @param evt defines the event details to be processed
  29011. */
  29012. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29013. /**
  29014. * Does this action manager handles actions of any of the given triggers
  29015. * @param triggers defines the triggers to be tested
  29016. * @return a boolean indicating whether one (or more) of the triggers is handled
  29017. */
  29018. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29019. /**
  29020. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29021. * speed.
  29022. * @param triggerA defines the trigger to be tested
  29023. * @param triggerB defines the trigger to be tested
  29024. * @return a boolean indicating whether one (or more) of the triggers is handled
  29025. */
  29026. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29027. /**
  29028. * Does this action manager handles actions of a given trigger
  29029. * @param trigger defines the trigger to be tested
  29030. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29031. * @return whether the trigger is handled
  29032. */
  29033. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29034. /**
  29035. * Serialize this manager to a JSON object
  29036. * @param name defines the property name to store this manager
  29037. * @returns a JSON representation of this manager
  29038. */
  29039. abstract serialize(name: string): any;
  29040. /**
  29041. * Registers an action to this action manager
  29042. * @param action defines the action to be registered
  29043. * @return the action amended (prepared) after registration
  29044. */
  29045. abstract registerAction(action: IAction): Nullable<IAction>;
  29046. /**
  29047. * Unregisters an action to this action manager
  29048. * @param action defines the action to be unregistered
  29049. * @return a boolean indicating whether the action has been unregistered
  29050. */
  29051. abstract unregisterAction(action: IAction): Boolean;
  29052. /**
  29053. * Does exist one action manager with at least one trigger
  29054. **/
  29055. static get HasTriggers(): boolean;
  29056. /**
  29057. * Does exist one action manager with at least one pick trigger
  29058. **/
  29059. static get HasPickTriggers(): boolean;
  29060. /**
  29061. * Does exist one action manager that handles actions of a given trigger
  29062. * @param trigger defines the trigger to be tested
  29063. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29064. **/
  29065. static HasSpecificTrigger(trigger: number): boolean;
  29066. }
  29067. }
  29068. declare module BABYLON {
  29069. /**
  29070. * Defines how a node can be built from a string name.
  29071. */
  29072. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29073. /**
  29074. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29075. */
  29076. export class Node implements IBehaviorAware<Node> {
  29077. /** @hidden */
  29078. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29079. private static _NodeConstructors;
  29080. /**
  29081. * Add a new node constructor
  29082. * @param type defines the type name of the node to construct
  29083. * @param constructorFunc defines the constructor function
  29084. */
  29085. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29086. /**
  29087. * Returns a node constructor based on type name
  29088. * @param type defines the type name
  29089. * @param name defines the new node name
  29090. * @param scene defines the hosting scene
  29091. * @param options defines optional options to transmit to constructors
  29092. * @returns the new constructor or null
  29093. */
  29094. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29095. /**
  29096. * Gets or sets the name of the node
  29097. */
  29098. name: string;
  29099. /**
  29100. * Gets or sets the id of the node
  29101. */
  29102. id: string;
  29103. /**
  29104. * Gets or sets the unique id of the node
  29105. */
  29106. uniqueId: number;
  29107. /**
  29108. * Gets or sets a string used to store user defined state for the node
  29109. */
  29110. state: string;
  29111. /**
  29112. * Gets or sets an object used to store user defined information for the node
  29113. */
  29114. metadata: any;
  29115. /**
  29116. * For internal use only. Please do not use.
  29117. */
  29118. reservedDataStore: any;
  29119. /**
  29120. * List of inspectable custom properties (used by the Inspector)
  29121. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29122. */
  29123. inspectableCustomProperties: IInspectable[];
  29124. private _doNotSerialize;
  29125. /**
  29126. * Gets or sets a boolean used to define if the node must be serialized
  29127. */
  29128. get doNotSerialize(): boolean;
  29129. set doNotSerialize(value: boolean);
  29130. /** @hidden */
  29131. _isDisposed: boolean;
  29132. /**
  29133. * Gets a list of Animations associated with the node
  29134. */
  29135. animations: Animation[];
  29136. protected _ranges: {
  29137. [name: string]: Nullable<AnimationRange>;
  29138. };
  29139. /**
  29140. * Callback raised when the node is ready to be used
  29141. */
  29142. onReady: Nullable<(node: Node) => void>;
  29143. private _isEnabled;
  29144. private _isParentEnabled;
  29145. private _isReady;
  29146. /** @hidden */
  29147. _currentRenderId: number;
  29148. private _parentUpdateId;
  29149. /** @hidden */
  29150. _childUpdateId: number;
  29151. /** @hidden */
  29152. _waitingParentId: Nullable<string>;
  29153. /** @hidden */
  29154. _scene: Scene;
  29155. /** @hidden */
  29156. _cache: any;
  29157. private _parentNode;
  29158. private _children;
  29159. /** @hidden */
  29160. _worldMatrix: Matrix;
  29161. /** @hidden */
  29162. _worldMatrixDeterminant: number;
  29163. /** @hidden */
  29164. _worldMatrixDeterminantIsDirty: boolean;
  29165. /** @hidden */
  29166. private _sceneRootNodesIndex;
  29167. /**
  29168. * Gets a boolean indicating if the node has been disposed
  29169. * @returns true if the node was disposed
  29170. */
  29171. isDisposed(): boolean;
  29172. /**
  29173. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29174. * @see https://doc.babylonjs.com/how_to/parenting
  29175. */
  29176. set parent(parent: Nullable<Node>);
  29177. get parent(): Nullable<Node>;
  29178. /** @hidden */
  29179. _addToSceneRootNodes(): void;
  29180. /** @hidden */
  29181. _removeFromSceneRootNodes(): void;
  29182. private _animationPropertiesOverride;
  29183. /**
  29184. * Gets or sets the animation properties override
  29185. */
  29186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29188. /**
  29189. * Gets a string idenfifying the name of the class
  29190. * @returns "Node" string
  29191. */
  29192. getClassName(): string;
  29193. /** @hidden */
  29194. readonly _isNode: boolean;
  29195. /**
  29196. * An event triggered when the mesh is disposed
  29197. */
  29198. onDisposeObservable: Observable<Node>;
  29199. private _onDisposeObserver;
  29200. /**
  29201. * Sets a callback that will be raised when the node will be disposed
  29202. */
  29203. set onDispose(callback: () => void);
  29204. /**
  29205. * Creates a new Node
  29206. * @param name the name and id to be given to this node
  29207. * @param scene the scene this node will be added to
  29208. */
  29209. constructor(name: string, scene?: Nullable<Scene>);
  29210. /**
  29211. * Gets the scene of the node
  29212. * @returns a scene
  29213. */
  29214. getScene(): Scene;
  29215. /**
  29216. * Gets the engine of the node
  29217. * @returns a Engine
  29218. */
  29219. getEngine(): Engine;
  29220. private _behaviors;
  29221. /**
  29222. * Attach a behavior to the node
  29223. * @see http://doc.babylonjs.com/features/behaviour
  29224. * @param behavior defines the behavior to attach
  29225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29226. * @returns the current Node
  29227. */
  29228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29229. /**
  29230. * Remove an attached behavior
  29231. * @see http://doc.babylonjs.com/features/behaviour
  29232. * @param behavior defines the behavior to attach
  29233. * @returns the current Node
  29234. */
  29235. removeBehavior(behavior: Behavior<Node>): Node;
  29236. /**
  29237. * Gets the list of attached behaviors
  29238. * @see http://doc.babylonjs.com/features/behaviour
  29239. */
  29240. get behaviors(): Behavior<Node>[];
  29241. /**
  29242. * Gets an attached behavior by name
  29243. * @param name defines the name of the behavior to look for
  29244. * @see http://doc.babylonjs.com/features/behaviour
  29245. * @returns null if behavior was not found else the requested behavior
  29246. */
  29247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29248. /**
  29249. * Returns the latest update of the World matrix
  29250. * @returns a Matrix
  29251. */
  29252. getWorldMatrix(): Matrix;
  29253. /** @hidden */
  29254. _getWorldMatrixDeterminant(): number;
  29255. /**
  29256. * Returns directly the latest state of the mesh World matrix.
  29257. * A Matrix is returned.
  29258. */
  29259. get worldMatrixFromCache(): Matrix;
  29260. /** @hidden */
  29261. _initCache(): void;
  29262. /** @hidden */
  29263. updateCache(force?: boolean): void;
  29264. /** @hidden */
  29265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29266. /** @hidden */
  29267. _updateCache(ignoreParentClass?: boolean): void;
  29268. /** @hidden */
  29269. _isSynchronized(): boolean;
  29270. /** @hidden */
  29271. _markSyncedWithParent(): void;
  29272. /** @hidden */
  29273. isSynchronizedWithParent(): boolean;
  29274. /** @hidden */
  29275. isSynchronized(): boolean;
  29276. /**
  29277. * Is this node ready to be used/rendered
  29278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29279. * @return true if the node is ready
  29280. */
  29281. isReady(completeCheck?: boolean): boolean;
  29282. /**
  29283. * Is this node enabled?
  29284. * 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
  29285. * @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
  29286. * @return whether this node (and its parent) is enabled
  29287. */
  29288. isEnabled(checkAncestors?: boolean): boolean;
  29289. /** @hidden */
  29290. protected _syncParentEnabledState(): void;
  29291. /**
  29292. * Set the enabled state of this node
  29293. * @param value defines the new enabled state
  29294. */
  29295. setEnabled(value: boolean): void;
  29296. /**
  29297. * Is this node a descendant of the given node?
  29298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29299. * @param ancestor defines the parent node to inspect
  29300. * @returns a boolean indicating if this node is a descendant of the given node
  29301. */
  29302. isDescendantOf(ancestor: Node): boolean;
  29303. /** @hidden */
  29304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29305. /**
  29306. * Will return all nodes that have this node as ascendant
  29307. * @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
  29308. * @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
  29309. * @return all children nodes of all types
  29310. */
  29311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29312. /**
  29313. * Get all child-meshes of this node
  29314. * @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)
  29315. * @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
  29316. * @returns an array of AbstractMesh
  29317. */
  29318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29319. /**
  29320. * Get all direct children of this node
  29321. * @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
  29322. * @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)
  29323. * @returns an array of Node
  29324. */
  29325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29326. /** @hidden */
  29327. _setReady(state: boolean): void;
  29328. /**
  29329. * Get an animation by name
  29330. * @param name defines the name of the animation to look for
  29331. * @returns null if not found else the requested animation
  29332. */
  29333. getAnimationByName(name: string): Nullable<Animation>;
  29334. /**
  29335. * Creates an animation range for this node
  29336. * @param name defines the name of the range
  29337. * @param from defines the starting key
  29338. * @param to defines the end key
  29339. */
  29340. createAnimationRange(name: string, from: number, to: number): void;
  29341. /**
  29342. * Delete a specific animation range
  29343. * @param name defines the name of the range to delete
  29344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29345. */
  29346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29347. /**
  29348. * Get an animation range by name
  29349. * @param name defines the name of the animation range to look for
  29350. * @returns null if not found else the requested animation range
  29351. */
  29352. getAnimationRange(name: string): Nullable<AnimationRange>;
  29353. /**
  29354. * Gets the list of all animation ranges defined on this node
  29355. * @returns an array
  29356. */
  29357. getAnimationRanges(): Nullable<AnimationRange>[];
  29358. /**
  29359. * Will start the animation sequence
  29360. * @param name defines the range frames for animation sequence
  29361. * @param loop defines if the animation should loop (false by default)
  29362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29364. * @returns the object created for this animation. If range does not exist, it will return null
  29365. */
  29366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29367. /**
  29368. * Serialize animation ranges into a JSON compatible object
  29369. * @returns serialization object
  29370. */
  29371. serializeAnimationRanges(): any;
  29372. /**
  29373. * Computes the world matrix of the node
  29374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29375. * @returns the world matrix
  29376. */
  29377. computeWorldMatrix(force?: boolean): Matrix;
  29378. /**
  29379. * Releases resources associated with this node.
  29380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29382. */
  29383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29384. /**
  29385. * Parse animation range data from a serialization object and store them into a given node
  29386. * @param node defines where to store the animation ranges
  29387. * @param parsedNode defines the serialization object to read data from
  29388. * @param scene defines the hosting scene
  29389. */
  29390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29391. /**
  29392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29394. * @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
  29395. * @returns the new bounding vectors
  29396. */
  29397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29398. min: Vector3;
  29399. max: Vector3;
  29400. };
  29401. }
  29402. }
  29403. declare module BABYLON {
  29404. /**
  29405. * @hidden
  29406. */
  29407. export class _IAnimationState {
  29408. key: number;
  29409. repeatCount: number;
  29410. workValue?: any;
  29411. loopMode?: number;
  29412. offsetValue?: any;
  29413. highLimitValue?: any;
  29414. }
  29415. /**
  29416. * Class used to store any kind of animation
  29417. */
  29418. export class Animation {
  29419. /**Name of the animation */
  29420. name: string;
  29421. /**Property to animate */
  29422. targetProperty: string;
  29423. /**The frames per second of the animation */
  29424. framePerSecond: number;
  29425. /**The data type of the animation */
  29426. dataType: number;
  29427. /**The loop mode of the animation */
  29428. loopMode?: number | undefined;
  29429. /**Specifies if blending should be enabled */
  29430. enableBlending?: boolean | undefined;
  29431. /**
  29432. * Use matrix interpolation instead of using direct key value when animating matrices
  29433. */
  29434. static AllowMatricesInterpolation: boolean;
  29435. /**
  29436. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29437. */
  29438. static AllowMatrixDecomposeForInterpolation: boolean;
  29439. /**
  29440. * Stores the key frames of the animation
  29441. */
  29442. private _keys;
  29443. /**
  29444. * Stores the easing function of the animation
  29445. */
  29446. private _easingFunction;
  29447. /**
  29448. * @hidden Internal use only
  29449. */
  29450. _runtimeAnimations: RuntimeAnimation[];
  29451. /**
  29452. * The set of event that will be linked to this animation
  29453. */
  29454. private _events;
  29455. /**
  29456. * Stores an array of target property paths
  29457. */
  29458. targetPropertyPath: string[];
  29459. /**
  29460. * Stores the blending speed of the animation
  29461. */
  29462. blendingSpeed: number;
  29463. /**
  29464. * Stores the animation ranges for the animation
  29465. */
  29466. private _ranges;
  29467. /**
  29468. * @hidden Internal use
  29469. */
  29470. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29471. /**
  29472. * Sets up an animation
  29473. * @param property The property to animate
  29474. * @param animationType The animation type to apply
  29475. * @param framePerSecond The frames per second of the animation
  29476. * @param easingFunction The easing function used in the animation
  29477. * @returns The created animation
  29478. */
  29479. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29480. /**
  29481. * Create and start an animation on a node
  29482. * @param name defines the name of the global animation that will be run on all nodes
  29483. * @param node defines the root node where the animation will take place
  29484. * @param targetProperty defines property to animate
  29485. * @param framePerSecond defines the number of frame per second yo use
  29486. * @param totalFrame defines the number of frames in total
  29487. * @param from defines the initial value
  29488. * @param to defines the final value
  29489. * @param loopMode defines which loop mode you want to use (off by default)
  29490. * @param easingFunction defines the easing function to use (linear by default)
  29491. * @param onAnimationEnd defines the callback to call when animation end
  29492. * @returns the animatable created for this animation
  29493. */
  29494. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29495. /**
  29496. * Create and start an animation on a node and its descendants
  29497. * @param name defines the name of the global animation that will be run on all nodes
  29498. * @param node defines the root node where the animation will take place
  29499. * @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
  29500. * @param targetProperty defines property to animate
  29501. * @param framePerSecond defines the number of frame per second to use
  29502. * @param totalFrame defines the number of frames in total
  29503. * @param from defines the initial value
  29504. * @param to defines the final value
  29505. * @param loopMode defines which loop mode you want to use (off by default)
  29506. * @param easingFunction defines the easing function to use (linear by default)
  29507. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29508. * @returns the list of animatables created for all nodes
  29509. * @example https://www.babylonjs-playground.com/#MH0VLI
  29510. */
  29511. 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[]>;
  29512. /**
  29513. * Creates a new animation, merges it with the existing animations and starts it
  29514. * @param name Name of the animation
  29515. * @param node Node which contains the scene that begins the animations
  29516. * @param targetProperty Specifies which property to animate
  29517. * @param framePerSecond The frames per second of the animation
  29518. * @param totalFrame The total number of frames
  29519. * @param from The frame at the beginning of the animation
  29520. * @param to The frame at the end of the animation
  29521. * @param loopMode Specifies the loop mode of the animation
  29522. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29523. * @param onAnimationEnd Callback to run once the animation is complete
  29524. * @returns Nullable animation
  29525. */
  29526. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29527. /**
  29528. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29529. * @param sourceAnimation defines the Animation containing keyframes to convert
  29530. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29531. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29532. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29533. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29534. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29535. */
  29536. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29537. /**
  29538. * Transition property of an host to the target Value
  29539. * @param property The property to transition
  29540. * @param targetValue The target Value of the property
  29541. * @param host The object where the property to animate belongs
  29542. * @param scene Scene used to run the animation
  29543. * @param frameRate Framerate (in frame/s) to use
  29544. * @param transition The transition type we want to use
  29545. * @param duration The duration of the animation, in milliseconds
  29546. * @param onAnimationEnd Callback trigger at the end of the animation
  29547. * @returns Nullable animation
  29548. */
  29549. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29550. /**
  29551. * Return the array of runtime animations currently using this animation
  29552. */
  29553. get runtimeAnimations(): RuntimeAnimation[];
  29554. /**
  29555. * Specifies if any of the runtime animations are currently running
  29556. */
  29557. get hasRunningRuntimeAnimations(): boolean;
  29558. /**
  29559. * Initializes the animation
  29560. * @param name Name of the animation
  29561. * @param targetProperty Property to animate
  29562. * @param framePerSecond The frames per second of the animation
  29563. * @param dataType The data type of the animation
  29564. * @param loopMode The loop mode of the animation
  29565. * @param enableBlending Specifies if blending should be enabled
  29566. */
  29567. constructor(
  29568. /**Name of the animation */
  29569. name: string,
  29570. /**Property to animate */
  29571. targetProperty: string,
  29572. /**The frames per second of the animation */
  29573. framePerSecond: number,
  29574. /**The data type of the animation */
  29575. dataType: number,
  29576. /**The loop mode of the animation */
  29577. loopMode?: number | undefined,
  29578. /**Specifies if blending should be enabled */
  29579. enableBlending?: boolean | undefined);
  29580. /**
  29581. * Converts the animation to a string
  29582. * @param fullDetails support for multiple levels of logging within scene loading
  29583. * @returns String form of the animation
  29584. */
  29585. toString(fullDetails?: boolean): string;
  29586. /**
  29587. * Add an event to this animation
  29588. * @param event Event to add
  29589. */
  29590. addEvent(event: AnimationEvent): void;
  29591. /**
  29592. * Remove all events found at the given frame
  29593. * @param frame The frame to remove events from
  29594. */
  29595. removeEvents(frame: number): void;
  29596. /**
  29597. * Retrieves all the events from the animation
  29598. * @returns Events from the animation
  29599. */
  29600. getEvents(): AnimationEvent[];
  29601. /**
  29602. * Creates an animation range
  29603. * @param name Name of the animation range
  29604. * @param from Starting frame of the animation range
  29605. * @param to Ending frame of the animation
  29606. */
  29607. createRange(name: string, from: number, to: number): void;
  29608. /**
  29609. * Deletes an animation range by name
  29610. * @param name Name of the animation range to delete
  29611. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29612. */
  29613. deleteRange(name: string, deleteFrames?: boolean): void;
  29614. /**
  29615. * Gets the animation range by name, or null if not defined
  29616. * @param name Name of the animation range
  29617. * @returns Nullable animation range
  29618. */
  29619. getRange(name: string): Nullable<AnimationRange>;
  29620. /**
  29621. * Gets the key frames from the animation
  29622. * @returns The key frames of the animation
  29623. */
  29624. getKeys(): Array<IAnimationKey>;
  29625. /**
  29626. * Gets the highest frame rate of the animation
  29627. * @returns Highest frame rate of the animation
  29628. */
  29629. getHighestFrame(): number;
  29630. /**
  29631. * Gets the easing function of the animation
  29632. * @returns Easing function of the animation
  29633. */
  29634. getEasingFunction(): IEasingFunction;
  29635. /**
  29636. * Sets the easing function of the animation
  29637. * @param easingFunction A custom mathematical formula for animation
  29638. */
  29639. setEasingFunction(easingFunction: EasingFunction): void;
  29640. /**
  29641. * Interpolates a scalar linearly
  29642. * @param startValue Start value of the animation curve
  29643. * @param endValue End value of the animation curve
  29644. * @param gradient Scalar amount to interpolate
  29645. * @returns Interpolated scalar value
  29646. */
  29647. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29648. /**
  29649. * Interpolates a scalar cubically
  29650. * @param startValue Start value of the animation curve
  29651. * @param outTangent End tangent of the animation
  29652. * @param endValue End value of the animation curve
  29653. * @param inTangent Start tangent of the animation curve
  29654. * @param gradient Scalar amount to interpolate
  29655. * @returns Interpolated scalar value
  29656. */
  29657. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29658. /**
  29659. * Interpolates a quaternion using a spherical linear interpolation
  29660. * @param startValue Start value of the animation curve
  29661. * @param endValue End value of the animation curve
  29662. * @param gradient Scalar amount to interpolate
  29663. * @returns Interpolated quaternion value
  29664. */
  29665. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29666. /**
  29667. * Interpolates a quaternion cubically
  29668. * @param startValue Start value of the animation curve
  29669. * @param outTangent End tangent of the animation curve
  29670. * @param endValue End value of the animation curve
  29671. * @param inTangent Start tangent of the animation curve
  29672. * @param gradient Scalar amount to interpolate
  29673. * @returns Interpolated quaternion value
  29674. */
  29675. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29676. /**
  29677. * Interpolates a Vector3 linearl
  29678. * @param startValue Start value of the animation curve
  29679. * @param endValue End value of the animation curve
  29680. * @param gradient Scalar amount to interpolate
  29681. * @returns Interpolated scalar value
  29682. */
  29683. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29684. /**
  29685. * Interpolates a Vector3 cubically
  29686. * @param startValue Start value of the animation curve
  29687. * @param outTangent End tangent of the animation
  29688. * @param endValue End value of the animation curve
  29689. * @param inTangent Start tangent of the animation curve
  29690. * @param gradient Scalar amount to interpolate
  29691. * @returns InterpolatedVector3 value
  29692. */
  29693. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29694. /**
  29695. * Interpolates a Vector2 linearly
  29696. * @param startValue Start value of the animation curve
  29697. * @param endValue End value of the animation curve
  29698. * @param gradient Scalar amount to interpolate
  29699. * @returns Interpolated Vector2 value
  29700. */
  29701. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29702. /**
  29703. * Interpolates a Vector2 cubically
  29704. * @param startValue Start value of the animation curve
  29705. * @param outTangent End tangent of the animation
  29706. * @param endValue End value of the animation curve
  29707. * @param inTangent Start tangent of the animation curve
  29708. * @param gradient Scalar amount to interpolate
  29709. * @returns Interpolated Vector2 value
  29710. */
  29711. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29712. /**
  29713. * Interpolates a size linearly
  29714. * @param startValue Start value of the animation curve
  29715. * @param endValue End value of the animation curve
  29716. * @param gradient Scalar amount to interpolate
  29717. * @returns Interpolated Size value
  29718. */
  29719. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29720. /**
  29721. * Interpolates a Color3 linearly
  29722. * @param startValue Start value of the animation curve
  29723. * @param endValue End value of the animation curve
  29724. * @param gradient Scalar amount to interpolate
  29725. * @returns Interpolated Color3 value
  29726. */
  29727. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29728. /**
  29729. * Interpolates a Color4 linearly
  29730. * @param startValue Start value of the animation curve
  29731. * @param endValue End value of the animation curve
  29732. * @param gradient Scalar amount to interpolate
  29733. * @returns Interpolated Color3 value
  29734. */
  29735. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29736. /**
  29737. * @hidden Internal use only
  29738. */
  29739. _getKeyValue(value: any): any;
  29740. /**
  29741. * @hidden Internal use only
  29742. */
  29743. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29744. /**
  29745. * Defines the function to use to interpolate matrices
  29746. * @param startValue defines the start matrix
  29747. * @param endValue defines the end matrix
  29748. * @param gradient defines the gradient between both matrices
  29749. * @param result defines an optional target matrix where to store the interpolation
  29750. * @returns the interpolated matrix
  29751. */
  29752. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29753. /**
  29754. * Makes a copy of the animation
  29755. * @returns Cloned animation
  29756. */
  29757. clone(): Animation;
  29758. /**
  29759. * Sets the key frames of the animation
  29760. * @param values The animation key frames to set
  29761. */
  29762. setKeys(values: Array<IAnimationKey>): void;
  29763. /**
  29764. * Serializes the animation to an object
  29765. * @returns Serialized object
  29766. */
  29767. serialize(): any;
  29768. /**
  29769. * Float animation type
  29770. */
  29771. static readonly ANIMATIONTYPE_FLOAT: number;
  29772. /**
  29773. * Vector3 animation type
  29774. */
  29775. static readonly ANIMATIONTYPE_VECTOR3: number;
  29776. /**
  29777. * Quaternion animation type
  29778. */
  29779. static readonly ANIMATIONTYPE_QUATERNION: number;
  29780. /**
  29781. * Matrix animation type
  29782. */
  29783. static readonly ANIMATIONTYPE_MATRIX: number;
  29784. /**
  29785. * Color3 animation type
  29786. */
  29787. static readonly ANIMATIONTYPE_COLOR3: number;
  29788. /**
  29789. * Color3 animation type
  29790. */
  29791. static readonly ANIMATIONTYPE_COLOR4: number;
  29792. /**
  29793. * Vector2 animation type
  29794. */
  29795. static readonly ANIMATIONTYPE_VECTOR2: number;
  29796. /**
  29797. * Size animation type
  29798. */
  29799. static readonly ANIMATIONTYPE_SIZE: number;
  29800. /**
  29801. * Relative Loop Mode
  29802. */
  29803. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29804. /**
  29805. * Cycle Loop Mode
  29806. */
  29807. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29808. /**
  29809. * Constant Loop Mode
  29810. */
  29811. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29812. /** @hidden */
  29813. static _UniversalLerp(left: any, right: any, amount: number): any;
  29814. /**
  29815. * Parses an animation object and creates an animation
  29816. * @param parsedAnimation Parsed animation object
  29817. * @returns Animation object
  29818. */
  29819. static Parse(parsedAnimation: any): Animation;
  29820. /**
  29821. * Appends the serialized animations from the source animations
  29822. * @param source Source containing the animations
  29823. * @param destination Target to store the animations
  29824. */
  29825. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29826. }
  29827. }
  29828. declare module BABYLON {
  29829. /**
  29830. * Interface containing an array of animations
  29831. */
  29832. export interface IAnimatable {
  29833. /**
  29834. * Array of animations
  29835. */
  29836. animations: Nullable<Array<Animation>>;
  29837. }
  29838. }
  29839. declare module BABYLON {
  29840. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29841. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29842. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29843. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29844. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29845. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29846. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29847. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29848. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29849. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29850. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29851. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29852. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29853. /**
  29854. * Decorator used to define property that can be serialized as reference to a camera
  29855. * @param sourceName defines the name of the property to decorate
  29856. */
  29857. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29858. /**
  29859. * Class used to help serialization objects
  29860. */
  29861. export class SerializationHelper {
  29862. /** @hidden */
  29863. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29864. /** @hidden */
  29865. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29866. /** @hidden */
  29867. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29868. /** @hidden */
  29869. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29870. /**
  29871. * Appends the serialized animations from the source animations
  29872. * @param source Source containing the animations
  29873. * @param destination Target to store the animations
  29874. */
  29875. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29876. /**
  29877. * Static function used to serialized a specific entity
  29878. * @param entity defines the entity to serialize
  29879. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29880. * @returns a JSON compatible object representing the serialization of the entity
  29881. */
  29882. static Serialize<T>(entity: T, serializationObject?: any): any;
  29883. /**
  29884. * Creates a new entity from a serialization data object
  29885. * @param creationFunction defines a function used to instanciated the new entity
  29886. * @param source defines the source serialization data
  29887. * @param scene defines the hosting scene
  29888. * @param rootUrl defines the root url for resources
  29889. * @returns a new entity
  29890. */
  29891. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29892. /**
  29893. * Clones an object
  29894. * @param creationFunction defines the function used to instanciate the new object
  29895. * @param source defines the source object
  29896. * @returns the cloned object
  29897. */
  29898. static Clone<T>(creationFunction: () => T, source: T): T;
  29899. /**
  29900. * Instanciates a new object based on a source one (some data will be shared between both object)
  29901. * @param creationFunction defines the function used to instanciate the new object
  29902. * @param source defines the source object
  29903. * @returns the new object
  29904. */
  29905. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29906. }
  29907. }
  29908. declare module BABYLON {
  29909. /**
  29910. * Class used to manipulate GUIDs
  29911. */
  29912. export class GUID {
  29913. /**
  29914. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29915. * Be aware Math.random() could cause collisions, but:
  29916. * "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"
  29917. * @returns a pseudo random id
  29918. */
  29919. static RandomId(): string;
  29920. }
  29921. }
  29922. declare module BABYLON {
  29923. /**
  29924. * Base class of all the textures in babylon.
  29925. * It groups all the common properties the materials, post process, lights... might need
  29926. * in order to make a correct use of the texture.
  29927. */
  29928. export class BaseTexture implements IAnimatable {
  29929. /**
  29930. * Default anisotropic filtering level for the application.
  29931. * It is set to 4 as a good tradeoff between perf and quality.
  29932. */
  29933. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29934. /**
  29935. * Gets or sets the unique id of the texture
  29936. */
  29937. uniqueId: number;
  29938. /**
  29939. * Define the name of the texture.
  29940. */
  29941. name: string;
  29942. /**
  29943. * Gets or sets an object used to store user defined information.
  29944. */
  29945. metadata: any;
  29946. /**
  29947. * For internal use only. Please do not use.
  29948. */
  29949. reservedDataStore: any;
  29950. private _hasAlpha;
  29951. /**
  29952. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29953. */
  29954. set hasAlpha(value: boolean);
  29955. get hasAlpha(): boolean;
  29956. /**
  29957. * Defines if the alpha value should be determined via the rgb values.
  29958. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29959. */
  29960. getAlphaFromRGB: boolean;
  29961. /**
  29962. * Intensity or strength of the texture.
  29963. * It is commonly used by materials to fine tune the intensity of the texture
  29964. */
  29965. level: number;
  29966. /**
  29967. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29968. * This is part of the texture as textures usually maps to one uv set.
  29969. */
  29970. coordinatesIndex: number;
  29971. private _coordinatesMode;
  29972. /**
  29973. * How a texture is mapped.
  29974. *
  29975. * | Value | Type | Description |
  29976. * | ----- | ----------------------------------- | ----------- |
  29977. * | 0 | EXPLICIT_MODE | |
  29978. * | 1 | SPHERICAL_MODE | |
  29979. * | 2 | PLANAR_MODE | |
  29980. * | 3 | CUBIC_MODE | |
  29981. * | 4 | PROJECTION_MODE | |
  29982. * | 5 | SKYBOX_MODE | |
  29983. * | 6 | INVCUBIC_MODE | |
  29984. * | 7 | EQUIRECTANGULAR_MODE | |
  29985. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29986. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29987. */
  29988. set coordinatesMode(value: number);
  29989. get coordinatesMode(): number;
  29990. /**
  29991. * | Value | Type | Description |
  29992. * | ----- | ------------------ | ----------- |
  29993. * | 0 | CLAMP_ADDRESSMODE | |
  29994. * | 1 | WRAP_ADDRESSMODE | |
  29995. * | 2 | MIRROR_ADDRESSMODE | |
  29996. */
  29997. wrapU: number;
  29998. /**
  29999. * | Value | Type | Description |
  30000. * | ----- | ------------------ | ----------- |
  30001. * | 0 | CLAMP_ADDRESSMODE | |
  30002. * | 1 | WRAP_ADDRESSMODE | |
  30003. * | 2 | MIRROR_ADDRESSMODE | |
  30004. */
  30005. wrapV: number;
  30006. /**
  30007. * | Value | Type | Description |
  30008. * | ----- | ------------------ | ----------- |
  30009. * | 0 | CLAMP_ADDRESSMODE | |
  30010. * | 1 | WRAP_ADDRESSMODE | |
  30011. * | 2 | MIRROR_ADDRESSMODE | |
  30012. */
  30013. wrapR: number;
  30014. /**
  30015. * With compliant hardware and browser (supporting anisotropic filtering)
  30016. * this defines the level of anisotropic filtering in the texture.
  30017. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30018. */
  30019. anisotropicFilteringLevel: number;
  30020. /**
  30021. * Define if the texture is a cube texture or if false a 2d texture.
  30022. */
  30023. get isCube(): boolean;
  30024. set isCube(value: boolean);
  30025. /**
  30026. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30027. */
  30028. get is3D(): boolean;
  30029. set is3D(value: boolean);
  30030. /**
  30031. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30032. */
  30033. get is2DArray(): boolean;
  30034. set is2DArray(value: boolean);
  30035. /**
  30036. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30037. * HDR texture are usually stored in linear space.
  30038. * This only impacts the PBR and Background materials
  30039. */
  30040. gammaSpace: boolean;
  30041. /**
  30042. * Gets or sets whether or not the texture contains RGBD data.
  30043. */
  30044. get isRGBD(): boolean;
  30045. set isRGBD(value: boolean);
  30046. /**
  30047. * Is Z inverted in the texture (useful in a cube texture).
  30048. */
  30049. invertZ: boolean;
  30050. /**
  30051. * Are mip maps generated for this texture or not.
  30052. */
  30053. get noMipmap(): boolean;
  30054. /**
  30055. * @hidden
  30056. */
  30057. lodLevelInAlpha: boolean;
  30058. /**
  30059. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30060. */
  30061. get lodGenerationOffset(): number;
  30062. set lodGenerationOffset(value: number);
  30063. /**
  30064. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30065. */
  30066. get lodGenerationScale(): number;
  30067. set lodGenerationScale(value: number);
  30068. /**
  30069. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30070. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30071. * average roughness values.
  30072. */
  30073. get linearSpecularLOD(): boolean;
  30074. set linearSpecularLOD(value: boolean);
  30075. /**
  30076. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30077. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30078. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30079. */
  30080. get irradianceTexture(): Nullable<BaseTexture>;
  30081. set irradianceTexture(value: Nullable<BaseTexture>);
  30082. /**
  30083. * Define if the texture is a render target.
  30084. */
  30085. isRenderTarget: boolean;
  30086. /**
  30087. * Define the unique id of the texture in the scene.
  30088. */
  30089. get uid(): string;
  30090. /**
  30091. * Return a string representation of the texture.
  30092. * @returns the texture as a string
  30093. */
  30094. toString(): string;
  30095. /**
  30096. * Get the class name of the texture.
  30097. * @returns "BaseTexture"
  30098. */
  30099. getClassName(): string;
  30100. /**
  30101. * Define the list of animation attached to the texture.
  30102. */
  30103. animations: Animation[];
  30104. /**
  30105. * An event triggered when the texture is disposed.
  30106. */
  30107. onDisposeObservable: Observable<BaseTexture>;
  30108. private _onDisposeObserver;
  30109. /**
  30110. * Callback triggered when the texture has been disposed.
  30111. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30112. */
  30113. set onDispose(callback: () => void);
  30114. /**
  30115. * Define the current state of the loading sequence when in delayed load mode.
  30116. */
  30117. delayLoadState: number;
  30118. private _scene;
  30119. /** @hidden */
  30120. _texture: Nullable<InternalTexture>;
  30121. private _uid;
  30122. /**
  30123. * Define if the texture is preventinga material to render or not.
  30124. * If not and the texture is not ready, the engine will use a default black texture instead.
  30125. */
  30126. get isBlocking(): boolean;
  30127. /**
  30128. * Instantiates a new BaseTexture.
  30129. * Base class of all the textures in babylon.
  30130. * It groups all the common properties the materials, post process, lights... might need
  30131. * in order to make a correct use of the texture.
  30132. * @param scene Define the scene the texture blongs to
  30133. */
  30134. constructor(scene: Nullable<Scene>);
  30135. /**
  30136. * Get the scene the texture belongs to.
  30137. * @returns the scene or null if undefined
  30138. */
  30139. getScene(): Nullable<Scene>;
  30140. /**
  30141. * Get the texture transform matrix used to offset tile the texture for istance.
  30142. * @returns the transformation matrix
  30143. */
  30144. getTextureMatrix(): Matrix;
  30145. /**
  30146. * Get the texture reflection matrix used to rotate/transform the reflection.
  30147. * @returns the reflection matrix
  30148. */
  30149. getReflectionTextureMatrix(): Matrix;
  30150. /**
  30151. * Get the underlying lower level texture from Babylon.
  30152. * @returns the insternal texture
  30153. */
  30154. getInternalTexture(): Nullable<InternalTexture>;
  30155. /**
  30156. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30157. * @returns true if ready or not blocking
  30158. */
  30159. isReadyOrNotBlocking(): boolean;
  30160. /**
  30161. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30162. * @returns true if fully ready
  30163. */
  30164. isReady(): boolean;
  30165. private _cachedSize;
  30166. /**
  30167. * Get the size of the texture.
  30168. * @returns the texture size.
  30169. */
  30170. getSize(): ISize;
  30171. /**
  30172. * Get the base size of the texture.
  30173. * It can be different from the size if the texture has been resized for POT for instance
  30174. * @returns the base size
  30175. */
  30176. getBaseSize(): ISize;
  30177. /**
  30178. * Update the sampling mode of the texture.
  30179. * Default is Trilinear mode.
  30180. *
  30181. * | Value | Type | Description |
  30182. * | ----- | ------------------ | ----------- |
  30183. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30184. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30185. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30186. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30187. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30188. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30189. * | 7 | NEAREST_LINEAR | |
  30190. * | 8 | NEAREST_NEAREST | |
  30191. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30192. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30193. * | 11 | LINEAR_LINEAR | |
  30194. * | 12 | LINEAR_NEAREST | |
  30195. *
  30196. * > _mag_: magnification filter (close to the viewer)
  30197. * > _min_: minification filter (far from the viewer)
  30198. * > _mip_: filter used between mip map levels
  30199. *@param samplingMode Define the new sampling mode of the texture
  30200. */
  30201. updateSamplingMode(samplingMode: number): void;
  30202. /**
  30203. * Scales the texture if is `canRescale()`
  30204. * @param ratio the resize factor we want to use to rescale
  30205. */
  30206. scale(ratio: number): void;
  30207. /**
  30208. * Get if the texture can rescale.
  30209. */
  30210. get canRescale(): boolean;
  30211. /** @hidden */
  30212. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30213. /** @hidden */
  30214. _rebuild(): void;
  30215. /**
  30216. * Triggers the load sequence in delayed load mode.
  30217. */
  30218. delayLoad(): void;
  30219. /**
  30220. * Clones the texture.
  30221. * @returns the cloned texture
  30222. */
  30223. clone(): Nullable<BaseTexture>;
  30224. /**
  30225. * Get the texture underlying type (INT, FLOAT...)
  30226. */
  30227. get textureType(): number;
  30228. /**
  30229. * Get the texture underlying format (RGB, RGBA...)
  30230. */
  30231. get textureFormat(): number;
  30232. /**
  30233. * Indicates that textures need to be re-calculated for all materials
  30234. */
  30235. protected _markAllSubMeshesAsTexturesDirty(): void;
  30236. /**
  30237. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30238. * This will returns an RGBA array buffer containing either in values (0-255) or
  30239. * float values (0-1) depending of the underlying buffer type.
  30240. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30241. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30242. * @param buffer defines a user defined buffer to fill with data (can be null)
  30243. * @returns The Array buffer containing the pixels data.
  30244. */
  30245. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30246. /**
  30247. * Release and destroy the underlying lower level texture aka internalTexture.
  30248. */
  30249. releaseInternalTexture(): void;
  30250. /** @hidden */
  30251. get _lodTextureHigh(): Nullable<BaseTexture>;
  30252. /** @hidden */
  30253. get _lodTextureMid(): Nullable<BaseTexture>;
  30254. /** @hidden */
  30255. get _lodTextureLow(): Nullable<BaseTexture>;
  30256. /**
  30257. * Dispose the texture and release its associated resources.
  30258. */
  30259. dispose(): void;
  30260. /**
  30261. * Serialize the texture into a JSON representation that can be parsed later on.
  30262. * @returns the JSON representation of the texture
  30263. */
  30264. serialize(): any;
  30265. /**
  30266. * Helper function to be called back once a list of texture contains only ready textures.
  30267. * @param textures Define the list of textures to wait for
  30268. * @param callback Define the callback triggered once the entire list will be ready
  30269. */
  30270. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30271. }
  30272. }
  30273. declare module BABYLON {
  30274. /**
  30275. * Options to be used when creating an effect.
  30276. */
  30277. export interface IEffectCreationOptions {
  30278. /**
  30279. * Atrributes that will be used in the shader.
  30280. */
  30281. attributes: string[];
  30282. /**
  30283. * Uniform varible names that will be set in the shader.
  30284. */
  30285. uniformsNames: string[];
  30286. /**
  30287. * Uniform buffer variable names that will be set in the shader.
  30288. */
  30289. uniformBuffersNames: string[];
  30290. /**
  30291. * Sampler texture variable names that will be set in the shader.
  30292. */
  30293. samplers: string[];
  30294. /**
  30295. * Define statements that will be set in the shader.
  30296. */
  30297. defines: any;
  30298. /**
  30299. * Possible fallbacks for this effect to improve performance when needed.
  30300. */
  30301. fallbacks: Nullable<IEffectFallbacks>;
  30302. /**
  30303. * Callback that will be called when the shader is compiled.
  30304. */
  30305. onCompiled: Nullable<(effect: Effect) => void>;
  30306. /**
  30307. * Callback that will be called if an error occurs during shader compilation.
  30308. */
  30309. onError: Nullable<(effect: Effect, errors: string) => void>;
  30310. /**
  30311. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30312. */
  30313. indexParameters?: any;
  30314. /**
  30315. * Max number of lights that can be used in the shader.
  30316. */
  30317. maxSimultaneousLights?: number;
  30318. /**
  30319. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30320. */
  30321. transformFeedbackVaryings?: Nullable<string[]>;
  30322. }
  30323. /**
  30324. * Effect containing vertex and fragment shader that can be executed on an object.
  30325. */
  30326. export class Effect implements IDisposable {
  30327. /**
  30328. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30329. */
  30330. static ShadersRepository: string;
  30331. /**
  30332. * Enable logging of the shader code when a compilation error occurs
  30333. */
  30334. static LogShaderCodeOnCompilationError: boolean;
  30335. /**
  30336. * Name of the effect.
  30337. */
  30338. name: any;
  30339. /**
  30340. * String container all the define statements that should be set on the shader.
  30341. */
  30342. defines: string;
  30343. /**
  30344. * Callback that will be called when the shader is compiled.
  30345. */
  30346. onCompiled: Nullable<(effect: Effect) => void>;
  30347. /**
  30348. * Callback that will be called if an error occurs during shader compilation.
  30349. */
  30350. onError: Nullable<(effect: Effect, errors: string) => void>;
  30351. /**
  30352. * Callback that will be called when effect is bound.
  30353. */
  30354. onBind: Nullable<(effect: Effect) => void>;
  30355. /**
  30356. * Unique ID of the effect.
  30357. */
  30358. uniqueId: number;
  30359. /**
  30360. * Observable that will be called when the shader is compiled.
  30361. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30362. */
  30363. onCompileObservable: Observable<Effect>;
  30364. /**
  30365. * Observable that will be called if an error occurs during shader compilation.
  30366. */
  30367. onErrorObservable: Observable<Effect>;
  30368. /** @hidden */
  30369. _onBindObservable: Nullable<Observable<Effect>>;
  30370. /**
  30371. * @hidden
  30372. * Specifies if the effect was previously ready
  30373. */
  30374. _wasPreviouslyReady: boolean;
  30375. /**
  30376. * Observable that will be called when effect is bound.
  30377. */
  30378. get onBindObservable(): Observable<Effect>;
  30379. /** @hidden */
  30380. _bonesComputationForcedToCPU: boolean;
  30381. private static _uniqueIdSeed;
  30382. private _engine;
  30383. private _uniformBuffersNames;
  30384. private _uniformsNames;
  30385. private _samplerList;
  30386. private _samplers;
  30387. private _isReady;
  30388. private _compilationError;
  30389. private _allFallbacksProcessed;
  30390. private _attributesNames;
  30391. private _attributes;
  30392. private _attributeLocationByName;
  30393. private _uniforms;
  30394. /**
  30395. * Key for the effect.
  30396. * @hidden
  30397. */
  30398. _key: string;
  30399. private _indexParameters;
  30400. private _fallbacks;
  30401. private _vertexSourceCode;
  30402. private _fragmentSourceCode;
  30403. private _vertexSourceCodeOverride;
  30404. private _fragmentSourceCodeOverride;
  30405. private _transformFeedbackVaryings;
  30406. /**
  30407. * Compiled shader to webGL program.
  30408. * @hidden
  30409. */
  30410. _pipelineContext: Nullable<IPipelineContext>;
  30411. private _valueCache;
  30412. private static _baseCache;
  30413. /**
  30414. * Instantiates an effect.
  30415. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30416. * @param baseName Name of the effect.
  30417. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30418. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30419. * @param samplers List of sampler variables that will be passed to the shader.
  30420. * @param engine Engine to be used to render the effect
  30421. * @param defines Define statements to be added to the shader.
  30422. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30423. * @param onCompiled Callback that will be called when the shader is compiled.
  30424. * @param onError Callback that will be called if an error occurs during shader compilation.
  30425. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30426. */
  30427. 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);
  30428. private _useFinalCode;
  30429. /**
  30430. * Unique key for this effect
  30431. */
  30432. get key(): string;
  30433. /**
  30434. * If the effect has been compiled and prepared.
  30435. * @returns if the effect is compiled and prepared.
  30436. */
  30437. isReady(): boolean;
  30438. private _isReadyInternal;
  30439. /**
  30440. * The engine the effect was initialized with.
  30441. * @returns the engine.
  30442. */
  30443. getEngine(): Engine;
  30444. /**
  30445. * The pipeline context for this effect
  30446. * @returns the associated pipeline context
  30447. */
  30448. getPipelineContext(): Nullable<IPipelineContext>;
  30449. /**
  30450. * The set of names of attribute variables for the shader.
  30451. * @returns An array of attribute names.
  30452. */
  30453. getAttributesNames(): string[];
  30454. /**
  30455. * Returns the attribute at the given index.
  30456. * @param index The index of the attribute.
  30457. * @returns The location of the attribute.
  30458. */
  30459. getAttributeLocation(index: number): number;
  30460. /**
  30461. * Returns the attribute based on the name of the variable.
  30462. * @param name of the attribute to look up.
  30463. * @returns the attribute location.
  30464. */
  30465. getAttributeLocationByName(name: string): number;
  30466. /**
  30467. * The number of attributes.
  30468. * @returns the numnber of attributes.
  30469. */
  30470. getAttributesCount(): number;
  30471. /**
  30472. * Gets the index of a uniform variable.
  30473. * @param uniformName of the uniform to look up.
  30474. * @returns the index.
  30475. */
  30476. getUniformIndex(uniformName: string): number;
  30477. /**
  30478. * Returns the attribute based on the name of the variable.
  30479. * @param uniformName of the uniform to look up.
  30480. * @returns the location of the uniform.
  30481. */
  30482. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30483. /**
  30484. * Returns an array of sampler variable names
  30485. * @returns The array of sampler variable neames.
  30486. */
  30487. getSamplers(): string[];
  30488. /**
  30489. * The error from the last compilation.
  30490. * @returns the error string.
  30491. */
  30492. getCompilationError(): string;
  30493. /**
  30494. * Gets a boolean indicating that all fallbacks were used during compilation
  30495. * @returns true if all fallbacks were used
  30496. */
  30497. allFallbacksProcessed(): boolean;
  30498. /**
  30499. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30500. * @param func The callback to be used.
  30501. */
  30502. executeWhenCompiled(func: (effect: Effect) => void): void;
  30503. private _checkIsReady;
  30504. private _loadShader;
  30505. /**
  30506. * Recompiles the webGL program
  30507. * @param vertexSourceCode The source code for the vertex shader.
  30508. * @param fragmentSourceCode The source code for the fragment shader.
  30509. * @param onCompiled Callback called when completed.
  30510. * @param onError Callback called on error.
  30511. * @hidden
  30512. */
  30513. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30514. /**
  30515. * Prepares the effect
  30516. * @hidden
  30517. */
  30518. _prepareEffect(): void;
  30519. private _getShaderCodeAndErrorLine;
  30520. private _processCompilationErrors;
  30521. /**
  30522. * Checks if the effect is supported. (Must be called after compilation)
  30523. */
  30524. get isSupported(): boolean;
  30525. /**
  30526. * Binds a texture to the engine to be used as output of the shader.
  30527. * @param channel Name of the output variable.
  30528. * @param texture Texture to bind.
  30529. * @hidden
  30530. */
  30531. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30532. /**
  30533. * Sets a texture on the engine to be used in the shader.
  30534. * @param channel Name of the sampler variable.
  30535. * @param texture Texture to set.
  30536. */
  30537. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30538. /**
  30539. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30540. * @param channel Name of the sampler variable.
  30541. * @param texture Texture to set.
  30542. */
  30543. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30544. /**
  30545. * Sets an array of textures on the engine to be used in the shader.
  30546. * @param channel Name of the variable.
  30547. * @param textures Textures to set.
  30548. */
  30549. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30550. /**
  30551. * 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)
  30552. * @param channel Name of the sampler variable.
  30553. * @param postProcess Post process to get the input texture from.
  30554. */
  30555. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30556. /**
  30557. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30558. * 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)
  30559. * @param channel Name of the sampler variable.
  30560. * @param postProcess Post process to get the output texture from.
  30561. */
  30562. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30563. /** @hidden */
  30564. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30565. /** @hidden */
  30566. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30567. /** @hidden */
  30568. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30569. /** @hidden */
  30570. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30571. /**
  30572. * Binds a buffer to a uniform.
  30573. * @param buffer Buffer to bind.
  30574. * @param name Name of the uniform variable to bind to.
  30575. */
  30576. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30577. /**
  30578. * Binds block to a uniform.
  30579. * @param blockName Name of the block to bind.
  30580. * @param index Index to bind.
  30581. */
  30582. bindUniformBlock(blockName: string, index: number): void;
  30583. /**
  30584. * Sets an interger value on a uniform variable.
  30585. * @param uniformName Name of the variable.
  30586. * @param value Value to be set.
  30587. * @returns this effect.
  30588. */
  30589. setInt(uniformName: string, value: number): Effect;
  30590. /**
  30591. * Sets an int array on a uniform variable.
  30592. * @param uniformName Name of the variable.
  30593. * @param array array to be set.
  30594. * @returns this effect.
  30595. */
  30596. setIntArray(uniformName: string, array: Int32Array): Effect;
  30597. /**
  30598. * 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)
  30599. * @param uniformName Name of the variable.
  30600. * @param array array to be set.
  30601. * @returns this effect.
  30602. */
  30603. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30604. /**
  30605. * 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)
  30606. * @param uniformName Name of the variable.
  30607. * @param array array to be set.
  30608. * @returns this effect.
  30609. */
  30610. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30611. /**
  30612. * 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)
  30613. * @param uniformName Name of the variable.
  30614. * @param array array to be set.
  30615. * @returns this effect.
  30616. */
  30617. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30618. /**
  30619. * Sets an float array on a uniform variable.
  30620. * @param uniformName Name of the variable.
  30621. * @param array array to be set.
  30622. * @returns this effect.
  30623. */
  30624. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30625. /**
  30626. * 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)
  30627. * @param uniformName Name of the variable.
  30628. * @param array array to be set.
  30629. * @returns this effect.
  30630. */
  30631. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30632. /**
  30633. * 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)
  30634. * @param uniformName Name of the variable.
  30635. * @param array array to be set.
  30636. * @returns this effect.
  30637. */
  30638. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30639. /**
  30640. * 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)
  30641. * @param uniformName Name of the variable.
  30642. * @param array array to be set.
  30643. * @returns this effect.
  30644. */
  30645. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30646. /**
  30647. * Sets an array on a uniform variable.
  30648. * @param uniformName Name of the variable.
  30649. * @param array array to be set.
  30650. * @returns this effect.
  30651. */
  30652. setArray(uniformName: string, array: number[]): Effect;
  30653. /**
  30654. * 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)
  30655. * @param uniformName Name of the variable.
  30656. * @param array array to be set.
  30657. * @returns this effect.
  30658. */
  30659. setArray2(uniformName: string, array: number[]): Effect;
  30660. /**
  30661. * 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)
  30662. * @param uniformName Name of the variable.
  30663. * @param array array to be set.
  30664. * @returns this effect.
  30665. */
  30666. setArray3(uniformName: string, array: number[]): Effect;
  30667. /**
  30668. * 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)
  30669. * @param uniformName Name of the variable.
  30670. * @param array array to be set.
  30671. * @returns this effect.
  30672. */
  30673. setArray4(uniformName: string, array: number[]): Effect;
  30674. /**
  30675. * Sets matrices on a uniform variable.
  30676. * @param uniformName Name of the variable.
  30677. * @param matrices matrices to be set.
  30678. * @returns this effect.
  30679. */
  30680. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30681. /**
  30682. * Sets matrix on a uniform variable.
  30683. * @param uniformName Name of the variable.
  30684. * @param matrix matrix to be set.
  30685. * @returns this effect.
  30686. */
  30687. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30688. /**
  30689. * 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)
  30690. * @param uniformName Name of the variable.
  30691. * @param matrix matrix to be set.
  30692. * @returns this effect.
  30693. */
  30694. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30695. /**
  30696. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30697. * @param uniformName Name of the variable.
  30698. * @param matrix matrix to be set.
  30699. * @returns this effect.
  30700. */
  30701. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30702. /**
  30703. * Sets a float on a uniform variable.
  30704. * @param uniformName Name of the variable.
  30705. * @param value value to be set.
  30706. * @returns this effect.
  30707. */
  30708. setFloat(uniformName: string, value: number): Effect;
  30709. /**
  30710. * Sets a boolean on a uniform variable.
  30711. * @param uniformName Name of the variable.
  30712. * @param bool value to be set.
  30713. * @returns this effect.
  30714. */
  30715. setBool(uniformName: string, bool: boolean): Effect;
  30716. /**
  30717. * Sets a Vector2 on a uniform variable.
  30718. * @param uniformName Name of the variable.
  30719. * @param vector2 vector2 to be set.
  30720. * @returns this effect.
  30721. */
  30722. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30723. /**
  30724. * Sets a float2 on a uniform variable.
  30725. * @param uniformName Name of the variable.
  30726. * @param x First float in float2.
  30727. * @param y Second float in float2.
  30728. * @returns this effect.
  30729. */
  30730. setFloat2(uniformName: string, x: number, y: number): Effect;
  30731. /**
  30732. * Sets a Vector3 on a uniform variable.
  30733. * @param uniformName Name of the variable.
  30734. * @param vector3 Value to be set.
  30735. * @returns this effect.
  30736. */
  30737. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30738. /**
  30739. * Sets a float3 on a uniform variable.
  30740. * @param uniformName Name of the variable.
  30741. * @param x First float in float3.
  30742. * @param y Second float in float3.
  30743. * @param z Third float in float3.
  30744. * @returns this effect.
  30745. */
  30746. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30747. /**
  30748. * Sets a Vector4 on a uniform variable.
  30749. * @param uniformName Name of the variable.
  30750. * @param vector4 Value to be set.
  30751. * @returns this effect.
  30752. */
  30753. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30754. /**
  30755. * Sets a float4 on a uniform variable.
  30756. * @param uniformName Name of the variable.
  30757. * @param x First float in float4.
  30758. * @param y Second float in float4.
  30759. * @param z Third float in float4.
  30760. * @param w Fourth float in float4.
  30761. * @returns this effect.
  30762. */
  30763. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30764. /**
  30765. * Sets a Color3 on a uniform variable.
  30766. * @param uniformName Name of the variable.
  30767. * @param color3 Value to be set.
  30768. * @returns this effect.
  30769. */
  30770. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30771. /**
  30772. * Sets a Color4 on a uniform variable.
  30773. * @param uniformName Name of the variable.
  30774. * @param color3 Value to be set.
  30775. * @param alpha Alpha value to be set.
  30776. * @returns this effect.
  30777. */
  30778. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30779. /**
  30780. * Sets a Color4 on a uniform variable
  30781. * @param uniformName defines the name of the variable
  30782. * @param color4 defines the value to be set
  30783. * @returns this effect.
  30784. */
  30785. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30786. /** Release all associated resources */
  30787. dispose(): void;
  30788. /**
  30789. * This function will add a new shader to the shader store
  30790. * @param name the name of the shader
  30791. * @param pixelShader optional pixel shader content
  30792. * @param vertexShader optional vertex shader content
  30793. */
  30794. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30795. /**
  30796. * Store of each shader (The can be looked up using effect.key)
  30797. */
  30798. static ShadersStore: {
  30799. [key: string]: string;
  30800. };
  30801. /**
  30802. * Store of each included file for a shader (The can be looked up using effect.key)
  30803. */
  30804. static IncludesShadersStore: {
  30805. [key: string]: string;
  30806. };
  30807. /**
  30808. * Resets the cache of effects.
  30809. */
  30810. static ResetCache(): void;
  30811. }
  30812. }
  30813. declare module BABYLON {
  30814. /**
  30815. * Interface used to describe the capabilities of the engine relatively to the current browser
  30816. */
  30817. export interface EngineCapabilities {
  30818. /** Maximum textures units per fragment shader */
  30819. maxTexturesImageUnits: number;
  30820. /** Maximum texture units per vertex shader */
  30821. maxVertexTextureImageUnits: number;
  30822. /** Maximum textures units in the entire pipeline */
  30823. maxCombinedTexturesImageUnits: number;
  30824. /** Maximum texture size */
  30825. maxTextureSize: number;
  30826. /** Maximum texture samples */
  30827. maxSamples?: number;
  30828. /** Maximum cube texture size */
  30829. maxCubemapTextureSize: number;
  30830. /** Maximum render texture size */
  30831. maxRenderTextureSize: number;
  30832. /** Maximum number of vertex attributes */
  30833. maxVertexAttribs: number;
  30834. /** Maximum number of varyings */
  30835. maxVaryingVectors: number;
  30836. /** Maximum number of uniforms per vertex shader */
  30837. maxVertexUniformVectors: number;
  30838. /** Maximum number of uniforms per fragment shader */
  30839. maxFragmentUniformVectors: number;
  30840. /** Defines if standard derivates (dx/dy) are supported */
  30841. standardDerivatives: boolean;
  30842. /** Defines if s3tc texture compression is supported */
  30843. s3tc?: WEBGL_compressed_texture_s3tc;
  30844. /** Defines if pvrtc texture compression is supported */
  30845. pvrtc: any;
  30846. /** Defines if etc1 texture compression is supported */
  30847. etc1: any;
  30848. /** Defines if etc2 texture compression is supported */
  30849. etc2: any;
  30850. /** Defines if astc texture compression is supported */
  30851. astc: any;
  30852. /** Defines if float textures are supported */
  30853. textureFloat: boolean;
  30854. /** Defines if vertex array objects are supported */
  30855. vertexArrayObject: boolean;
  30856. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30857. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30858. /** Gets the maximum level of anisotropy supported */
  30859. maxAnisotropy: number;
  30860. /** Defines if instancing is supported */
  30861. instancedArrays: boolean;
  30862. /** Defines if 32 bits indices are supported */
  30863. uintIndices: boolean;
  30864. /** Defines if high precision shaders are supported */
  30865. highPrecisionShaderSupported: boolean;
  30866. /** Defines if depth reading in the fragment shader is supported */
  30867. fragmentDepthSupported: boolean;
  30868. /** Defines if float texture linear filtering is supported*/
  30869. textureFloatLinearFiltering: boolean;
  30870. /** Defines if rendering to float textures is supported */
  30871. textureFloatRender: boolean;
  30872. /** Defines if half float textures are supported*/
  30873. textureHalfFloat: boolean;
  30874. /** Defines if half float texture linear filtering is supported*/
  30875. textureHalfFloatLinearFiltering: boolean;
  30876. /** Defines if rendering to half float textures is supported */
  30877. textureHalfFloatRender: boolean;
  30878. /** Defines if textureLOD shader command is supported */
  30879. textureLOD: boolean;
  30880. /** Defines if draw buffers extension is supported */
  30881. drawBuffersExtension: boolean;
  30882. /** Defines if depth textures are supported */
  30883. depthTextureExtension: boolean;
  30884. /** Defines if float color buffer are supported */
  30885. colorBufferFloat: boolean;
  30886. /** Gets disjoint timer query extension (null if not supported) */
  30887. timerQuery?: EXT_disjoint_timer_query;
  30888. /** Defines if timestamp can be used with timer query */
  30889. canUseTimestampForTimerQuery: boolean;
  30890. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30891. multiview?: any;
  30892. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30893. oculusMultiview?: any;
  30894. /** Function used to let the system compiles shaders in background */
  30895. parallelShaderCompile?: {
  30896. COMPLETION_STATUS_KHR: number;
  30897. };
  30898. /** Max number of texture samples for MSAA */
  30899. maxMSAASamples: number;
  30900. /** Defines if the blend min max extension is supported */
  30901. blendMinMax: boolean;
  30902. }
  30903. }
  30904. declare module BABYLON {
  30905. /**
  30906. * @hidden
  30907. **/
  30908. export class DepthCullingState {
  30909. private _isDepthTestDirty;
  30910. private _isDepthMaskDirty;
  30911. private _isDepthFuncDirty;
  30912. private _isCullFaceDirty;
  30913. private _isCullDirty;
  30914. private _isZOffsetDirty;
  30915. private _isFrontFaceDirty;
  30916. private _depthTest;
  30917. private _depthMask;
  30918. private _depthFunc;
  30919. private _cull;
  30920. private _cullFace;
  30921. private _zOffset;
  30922. private _frontFace;
  30923. /**
  30924. * Initializes the state.
  30925. */
  30926. constructor();
  30927. get isDirty(): boolean;
  30928. get zOffset(): number;
  30929. set zOffset(value: number);
  30930. get cullFace(): Nullable<number>;
  30931. set cullFace(value: Nullable<number>);
  30932. get cull(): Nullable<boolean>;
  30933. set cull(value: Nullable<boolean>);
  30934. get depthFunc(): Nullable<number>;
  30935. set depthFunc(value: Nullable<number>);
  30936. get depthMask(): boolean;
  30937. set depthMask(value: boolean);
  30938. get depthTest(): boolean;
  30939. set depthTest(value: boolean);
  30940. get frontFace(): Nullable<number>;
  30941. set frontFace(value: Nullable<number>);
  30942. reset(): void;
  30943. apply(gl: WebGLRenderingContext): void;
  30944. }
  30945. }
  30946. declare module BABYLON {
  30947. /**
  30948. * @hidden
  30949. **/
  30950. export class StencilState {
  30951. /** 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 */
  30952. static readonly ALWAYS: number;
  30953. /** Passed to stencilOperation to specify that stencil value must be kept */
  30954. static readonly KEEP: number;
  30955. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30956. static readonly REPLACE: number;
  30957. private _isStencilTestDirty;
  30958. private _isStencilMaskDirty;
  30959. private _isStencilFuncDirty;
  30960. private _isStencilOpDirty;
  30961. private _stencilTest;
  30962. private _stencilMask;
  30963. private _stencilFunc;
  30964. private _stencilFuncRef;
  30965. private _stencilFuncMask;
  30966. private _stencilOpStencilFail;
  30967. private _stencilOpDepthFail;
  30968. private _stencilOpStencilDepthPass;
  30969. get isDirty(): boolean;
  30970. get stencilFunc(): number;
  30971. set stencilFunc(value: number);
  30972. get stencilFuncRef(): number;
  30973. set stencilFuncRef(value: number);
  30974. get stencilFuncMask(): number;
  30975. set stencilFuncMask(value: number);
  30976. get stencilOpStencilFail(): number;
  30977. set stencilOpStencilFail(value: number);
  30978. get stencilOpDepthFail(): number;
  30979. set stencilOpDepthFail(value: number);
  30980. get stencilOpStencilDepthPass(): number;
  30981. set stencilOpStencilDepthPass(value: number);
  30982. get stencilMask(): number;
  30983. set stencilMask(value: number);
  30984. get stencilTest(): boolean;
  30985. set stencilTest(value: boolean);
  30986. constructor();
  30987. reset(): void;
  30988. apply(gl: WebGLRenderingContext): void;
  30989. }
  30990. }
  30991. declare module BABYLON {
  30992. /**
  30993. * @hidden
  30994. **/
  30995. export class AlphaState {
  30996. private _isAlphaBlendDirty;
  30997. private _isBlendFunctionParametersDirty;
  30998. private _isBlendEquationParametersDirty;
  30999. private _isBlendConstantsDirty;
  31000. private _alphaBlend;
  31001. private _blendFunctionParameters;
  31002. private _blendEquationParameters;
  31003. private _blendConstants;
  31004. /**
  31005. * Initializes the state.
  31006. */
  31007. constructor();
  31008. get isDirty(): boolean;
  31009. get alphaBlend(): boolean;
  31010. set alphaBlend(value: boolean);
  31011. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31012. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31013. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31014. reset(): void;
  31015. apply(gl: WebGLRenderingContext): void;
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /** @hidden */
  31020. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31021. attributeProcessor(attribute: string): string;
  31022. varyingProcessor(varying: string, isFragment: boolean): string;
  31023. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31024. }
  31025. }
  31026. declare module BABYLON {
  31027. /**
  31028. * Interface for attribute information associated with buffer instanciation
  31029. */
  31030. export interface InstancingAttributeInfo {
  31031. /**
  31032. * Name of the GLSL attribute
  31033. * if attribute index is not specified, this is used to retrieve the index from the effect
  31034. */
  31035. attributeName: string;
  31036. /**
  31037. * Index/offset of the attribute in the vertex shader
  31038. * if not specified, this will be computes from the name.
  31039. */
  31040. index?: number;
  31041. /**
  31042. * size of the attribute, 1, 2, 3 or 4
  31043. */
  31044. attributeSize: number;
  31045. /**
  31046. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31047. */
  31048. offset: number;
  31049. /**
  31050. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31051. * default to 1
  31052. */
  31053. divisor?: number;
  31054. /**
  31055. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31056. * default is FLOAT
  31057. */
  31058. attributeType?: number;
  31059. /**
  31060. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31061. */
  31062. normalized?: boolean;
  31063. }
  31064. }
  31065. declare module BABYLON {
  31066. interface ThinEngine {
  31067. /**
  31068. * Update a video texture
  31069. * @param texture defines the texture to update
  31070. * @param video defines the video element to use
  31071. * @param invertY defines if data must be stored with Y axis inverted
  31072. */
  31073. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31074. }
  31075. }
  31076. declare module BABYLON {
  31077. /**
  31078. * Settings for finer control over video usage
  31079. */
  31080. export interface VideoTextureSettings {
  31081. /**
  31082. * Applies `autoplay` to video, if specified
  31083. */
  31084. autoPlay?: boolean;
  31085. /**
  31086. * Applies `loop` to video, if specified
  31087. */
  31088. loop?: boolean;
  31089. /**
  31090. * Automatically updates internal texture from video at every frame in the render loop
  31091. */
  31092. autoUpdateTexture: boolean;
  31093. /**
  31094. * Image src displayed during the video loading or until the user interacts with the video.
  31095. */
  31096. poster?: string;
  31097. }
  31098. /**
  31099. * If you want to display a video in your scene, this is the special texture for that.
  31100. * This special texture works similar to other textures, with the exception of a few parameters.
  31101. * @see https://doc.babylonjs.com/how_to/video_texture
  31102. */
  31103. export class VideoTexture extends Texture {
  31104. /**
  31105. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31106. */
  31107. readonly autoUpdateTexture: boolean;
  31108. /**
  31109. * The video instance used by the texture internally
  31110. */
  31111. readonly video: HTMLVideoElement;
  31112. private _onUserActionRequestedObservable;
  31113. /**
  31114. * Event triggerd when a dom action is required by the user to play the video.
  31115. * This happens due to recent changes in browser policies preventing video to auto start.
  31116. */
  31117. get onUserActionRequestedObservable(): Observable<Texture>;
  31118. private _generateMipMaps;
  31119. private _engine;
  31120. private _stillImageCaptured;
  31121. private _displayingPosterTexture;
  31122. private _settings;
  31123. private _createInternalTextureOnEvent;
  31124. private _frameId;
  31125. private _currentSrc;
  31126. /**
  31127. * Creates a video texture.
  31128. * If you want to display a video in your scene, this is the special texture for that.
  31129. * This special texture works similar to other textures, with the exception of a few parameters.
  31130. * @see https://doc.babylonjs.com/how_to/video_texture
  31131. * @param name optional name, will detect from video source, if not defined
  31132. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31133. * @param scene is obviously the current scene.
  31134. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31135. * @param invertY is false by default but can be used to invert video on Y axis
  31136. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31137. * @param settings allows finer control over video usage
  31138. */
  31139. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31140. private _getName;
  31141. private _getVideo;
  31142. private _createInternalTexture;
  31143. private reset;
  31144. /**
  31145. * @hidden Internal method to initiate `update`.
  31146. */
  31147. _rebuild(): void;
  31148. /**
  31149. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31150. */
  31151. update(): void;
  31152. /**
  31153. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31154. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31155. */
  31156. updateTexture(isVisible: boolean): void;
  31157. protected _updateInternalTexture: () => void;
  31158. /**
  31159. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31160. * @param url New url.
  31161. */
  31162. updateURL(url: string): void;
  31163. /**
  31164. * Clones the texture.
  31165. * @returns the cloned texture
  31166. */
  31167. clone(): VideoTexture;
  31168. /**
  31169. * Dispose the texture and release its associated resources.
  31170. */
  31171. dispose(): void;
  31172. /**
  31173. * Creates a video texture straight from a stream.
  31174. * @param scene Define the scene the texture should be created in
  31175. * @param stream Define the stream the texture should be created from
  31176. * @returns The created video texture as a promise
  31177. */
  31178. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31179. /**
  31180. * Creates a video texture straight from your WebCam video feed.
  31181. * @param scene Define the scene the texture should be created in
  31182. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31183. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31184. * @returns The created video texture as a promise
  31185. */
  31186. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31187. minWidth: number;
  31188. maxWidth: number;
  31189. minHeight: number;
  31190. maxHeight: number;
  31191. deviceId: string;
  31192. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31193. /**
  31194. * Creates a video texture straight from your WebCam video feed.
  31195. * @param scene Define the scene the texture should be created in
  31196. * @param onReady Define a callback to triggered once the texture will be ready
  31197. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31198. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31199. */
  31200. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31201. minWidth: number;
  31202. maxWidth: number;
  31203. minHeight: number;
  31204. maxHeight: number;
  31205. deviceId: string;
  31206. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31207. }
  31208. }
  31209. declare module BABYLON {
  31210. /**
  31211. * Defines the interface used by objects working like Scene
  31212. * @hidden
  31213. */
  31214. export interface ISceneLike {
  31215. _addPendingData(data: any): void;
  31216. _removePendingData(data: any): void;
  31217. offlineProvider: IOfflineProvider;
  31218. }
  31219. /** Interface defining initialization parameters for Engine class */
  31220. export interface EngineOptions extends WebGLContextAttributes {
  31221. /**
  31222. * Defines if the engine should no exceed a specified device ratio
  31223. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31224. */
  31225. limitDeviceRatio?: number;
  31226. /**
  31227. * Defines if webvr should be enabled automatically
  31228. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31229. */
  31230. autoEnableWebVR?: boolean;
  31231. /**
  31232. * Defines if webgl2 should be turned off even if supported
  31233. * @see http://doc.babylonjs.com/features/webgl2
  31234. */
  31235. disableWebGL2Support?: boolean;
  31236. /**
  31237. * Defines if webaudio should be initialized as well
  31238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31239. */
  31240. audioEngine?: boolean;
  31241. /**
  31242. * Defines if animations should run using a deterministic lock step
  31243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31244. */
  31245. deterministicLockstep?: boolean;
  31246. /** Defines the maximum steps to use with deterministic lock step mode */
  31247. lockstepMaxSteps?: number;
  31248. /** Defines the seconds between each deterministic lock step */
  31249. timeStep?: number;
  31250. /**
  31251. * Defines that engine should ignore context lost events
  31252. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31253. */
  31254. doNotHandleContextLost?: boolean;
  31255. /**
  31256. * Defines that engine should ignore modifying touch action attribute and style
  31257. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31258. */
  31259. doNotHandleTouchAction?: boolean;
  31260. /**
  31261. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31262. */
  31263. useHighPrecisionFloats?: boolean;
  31264. }
  31265. /**
  31266. * The base engine class (root of all engines)
  31267. */
  31268. export class ThinEngine {
  31269. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31270. static ExceptionList: ({
  31271. key: string;
  31272. capture: string;
  31273. captureConstraint: number;
  31274. targets: string[];
  31275. } | {
  31276. key: string;
  31277. capture: null;
  31278. captureConstraint: null;
  31279. targets: string[];
  31280. })[];
  31281. /** @hidden */
  31282. static _TextureLoaders: IInternalTextureLoader[];
  31283. /**
  31284. * Returns the current npm package of the sdk
  31285. */
  31286. static get NpmPackage(): string;
  31287. /**
  31288. * Returns the current version of the framework
  31289. */
  31290. static get Version(): string;
  31291. /**
  31292. * Returns a string describing the current engine
  31293. */
  31294. get description(): string;
  31295. /**
  31296. * Gets or sets the epsilon value used by collision engine
  31297. */
  31298. static CollisionsEpsilon: number;
  31299. /**
  31300. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31301. */
  31302. static get ShadersRepository(): string;
  31303. static set ShadersRepository(value: string);
  31304. /** @hidden */
  31305. _shaderProcessor: IShaderProcessor;
  31306. /**
  31307. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31308. */
  31309. forcePOTTextures: boolean;
  31310. /**
  31311. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31312. */
  31313. isFullscreen: boolean;
  31314. /**
  31315. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31316. */
  31317. cullBackFaces: boolean;
  31318. /**
  31319. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31320. */
  31321. renderEvenInBackground: boolean;
  31322. /**
  31323. * Gets or sets a boolean indicating that cache can be kept between frames
  31324. */
  31325. preventCacheWipeBetweenFrames: boolean;
  31326. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31327. validateShaderPrograms: boolean;
  31328. /**
  31329. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31330. * This can provide greater z depth for distant objects.
  31331. */
  31332. useReverseDepthBuffer: boolean;
  31333. /**
  31334. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31335. */
  31336. disableUniformBuffers: boolean;
  31337. /** @hidden */
  31338. _uniformBuffers: UniformBuffer[];
  31339. /**
  31340. * Gets a boolean indicating that the engine supports uniform buffers
  31341. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31342. */
  31343. get supportsUniformBuffers(): boolean;
  31344. /** @hidden */
  31345. _gl: WebGLRenderingContext;
  31346. /** @hidden */
  31347. _webGLVersion: number;
  31348. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31349. protected _windowIsBackground: boolean;
  31350. protected _creationOptions: EngineOptions;
  31351. protected _highPrecisionShadersAllowed: boolean;
  31352. /** @hidden */
  31353. get _shouldUseHighPrecisionShader(): boolean;
  31354. /**
  31355. * Gets a boolean indicating that only power of 2 textures are supported
  31356. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31357. */
  31358. get needPOTTextures(): boolean;
  31359. /** @hidden */
  31360. _badOS: boolean;
  31361. /** @hidden */
  31362. _badDesktopOS: boolean;
  31363. private _hardwareScalingLevel;
  31364. /** @hidden */
  31365. _caps: EngineCapabilities;
  31366. private _isStencilEnable;
  31367. private _glVersion;
  31368. private _glRenderer;
  31369. private _glVendor;
  31370. /** @hidden */
  31371. _videoTextureSupported: boolean;
  31372. protected _renderingQueueLaunched: boolean;
  31373. protected _activeRenderLoops: (() => void)[];
  31374. /**
  31375. * Observable signaled when a context lost event is raised
  31376. */
  31377. onContextLostObservable: Observable<ThinEngine>;
  31378. /**
  31379. * Observable signaled when a context restored event is raised
  31380. */
  31381. onContextRestoredObservable: Observable<ThinEngine>;
  31382. private _onContextLost;
  31383. private _onContextRestored;
  31384. protected _contextWasLost: boolean;
  31385. /** @hidden */
  31386. _doNotHandleContextLost: boolean;
  31387. /**
  31388. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31389. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31390. */
  31391. get doNotHandleContextLost(): boolean;
  31392. set doNotHandleContextLost(value: boolean);
  31393. /**
  31394. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31395. */
  31396. disableVertexArrayObjects: boolean;
  31397. /** @hidden */
  31398. protected _colorWrite: boolean;
  31399. /** @hidden */
  31400. protected _colorWriteChanged: boolean;
  31401. /** @hidden */
  31402. protected _depthCullingState: DepthCullingState;
  31403. /** @hidden */
  31404. protected _stencilState: StencilState;
  31405. /** @hidden */
  31406. _alphaState: AlphaState;
  31407. /** @hidden */
  31408. _alphaMode: number;
  31409. /** @hidden */
  31410. _alphaEquation: number;
  31411. /** @hidden */
  31412. _internalTexturesCache: InternalTexture[];
  31413. /** @hidden */
  31414. protected _activeChannel: number;
  31415. private _currentTextureChannel;
  31416. /** @hidden */
  31417. protected _boundTexturesCache: {
  31418. [key: string]: Nullable<InternalTexture>;
  31419. };
  31420. /** @hidden */
  31421. protected _currentEffect: Nullable<Effect>;
  31422. /** @hidden */
  31423. protected _currentProgram: Nullable<WebGLProgram>;
  31424. private _compiledEffects;
  31425. private _vertexAttribArraysEnabled;
  31426. /** @hidden */
  31427. protected _cachedViewport: Nullable<IViewportLike>;
  31428. private _cachedVertexArrayObject;
  31429. /** @hidden */
  31430. protected _cachedVertexBuffers: any;
  31431. /** @hidden */
  31432. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31433. /** @hidden */
  31434. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31435. /** @hidden */
  31436. _currentRenderTarget: Nullable<InternalTexture>;
  31437. private _uintIndicesCurrentlySet;
  31438. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31439. /** @hidden */
  31440. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31441. private _currentBufferPointers;
  31442. private _currentInstanceLocations;
  31443. private _currentInstanceBuffers;
  31444. private _textureUnits;
  31445. /** @hidden */
  31446. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31447. /** @hidden */
  31448. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31449. /** @hidden */
  31450. _boundRenderFunction: any;
  31451. private _vaoRecordInProgress;
  31452. private _mustWipeVertexAttributes;
  31453. private _emptyTexture;
  31454. private _emptyCubeTexture;
  31455. private _emptyTexture3D;
  31456. private _emptyTexture2DArray;
  31457. /** @hidden */
  31458. _frameHandler: number;
  31459. private _nextFreeTextureSlots;
  31460. private _maxSimultaneousTextures;
  31461. private _activeRequests;
  31462. /** @hidden */
  31463. _transformTextureUrl: Nullable<(url: string) => string>;
  31464. protected get _supportsHardwareTextureRescaling(): boolean;
  31465. private _framebufferDimensionsObject;
  31466. /**
  31467. * sets the object from which width and height will be taken from when getting render width and height
  31468. * Will fallback to the gl object
  31469. * @param dimensions the framebuffer width and height that will be used.
  31470. */
  31471. set framebufferDimensionsObject(dimensions: Nullable<{
  31472. framebufferWidth: number;
  31473. framebufferHeight: number;
  31474. }>);
  31475. /**
  31476. * Gets the current viewport
  31477. */
  31478. get currentViewport(): Nullable<IViewportLike>;
  31479. /**
  31480. * Gets the default empty texture
  31481. */
  31482. get emptyTexture(): InternalTexture;
  31483. /**
  31484. * Gets the default empty 3D texture
  31485. */
  31486. get emptyTexture3D(): InternalTexture;
  31487. /**
  31488. * Gets the default empty 2D array texture
  31489. */
  31490. get emptyTexture2DArray(): InternalTexture;
  31491. /**
  31492. * Gets the default empty cube texture
  31493. */
  31494. get emptyCubeTexture(): InternalTexture;
  31495. /**
  31496. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31497. */
  31498. readonly premultipliedAlpha: boolean;
  31499. /**
  31500. * Observable event triggered before each texture is initialized
  31501. */
  31502. onBeforeTextureInitObservable: Observable<Texture>;
  31503. /**
  31504. * Creates a new engine
  31505. * @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
  31506. * @param antialias defines enable antialiasing (default: false)
  31507. * @param options defines further options to be sent to the getContext() function
  31508. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31509. */
  31510. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31511. private _rebuildInternalTextures;
  31512. private _rebuildEffects;
  31513. /**
  31514. * Gets a boolean indicating if all created effects are ready
  31515. * @returns true if all effects are ready
  31516. */
  31517. areAllEffectsReady(): boolean;
  31518. protected _rebuildBuffers(): void;
  31519. protected _initGLContext(): void;
  31520. /**
  31521. * Gets version of the current webGL context
  31522. */
  31523. get webGLVersion(): number;
  31524. /**
  31525. * Gets a string idenfifying the name of the class
  31526. * @returns "Engine" string
  31527. */
  31528. getClassName(): string;
  31529. /**
  31530. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31531. */
  31532. get isStencilEnable(): boolean;
  31533. /** @hidden */
  31534. _prepareWorkingCanvas(): void;
  31535. /**
  31536. * Reset the texture cache to empty state
  31537. */
  31538. resetTextureCache(): void;
  31539. /**
  31540. * Gets an object containing information about the current webGL context
  31541. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31542. */
  31543. getGlInfo(): {
  31544. vendor: string;
  31545. renderer: string;
  31546. version: string;
  31547. };
  31548. /**
  31549. * Defines the hardware scaling level.
  31550. * By default the hardware scaling level is computed from the window device ratio.
  31551. * 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.
  31552. * @param level defines the level to use
  31553. */
  31554. setHardwareScalingLevel(level: number): void;
  31555. /**
  31556. * Gets the current hardware scaling level.
  31557. * By default the hardware scaling level is computed from the window device ratio.
  31558. * 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.
  31559. * @returns a number indicating the current hardware scaling level
  31560. */
  31561. getHardwareScalingLevel(): number;
  31562. /**
  31563. * Gets the list of loaded textures
  31564. * @returns an array containing all loaded textures
  31565. */
  31566. getLoadedTexturesCache(): InternalTexture[];
  31567. /**
  31568. * Gets the object containing all engine capabilities
  31569. * @returns the EngineCapabilities object
  31570. */
  31571. getCaps(): EngineCapabilities;
  31572. /**
  31573. * stop executing a render loop function and remove it from the execution array
  31574. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31575. */
  31576. stopRenderLoop(renderFunction?: () => void): void;
  31577. /** @hidden */
  31578. _renderLoop(): void;
  31579. /**
  31580. * Gets the HTML canvas attached with the current webGL context
  31581. * @returns a HTML canvas
  31582. */
  31583. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31584. /**
  31585. * Gets host window
  31586. * @returns the host window object
  31587. */
  31588. getHostWindow(): Nullable<Window>;
  31589. /**
  31590. * Gets the current render width
  31591. * @param useScreen defines if screen size must be used (or the current render target if any)
  31592. * @returns a number defining the current render width
  31593. */
  31594. getRenderWidth(useScreen?: boolean): number;
  31595. /**
  31596. * Gets the current render height
  31597. * @param useScreen defines if screen size must be used (or the current render target if any)
  31598. * @returns a number defining the current render height
  31599. */
  31600. getRenderHeight(useScreen?: boolean): number;
  31601. /**
  31602. * Can be used to override the current requestAnimationFrame requester.
  31603. * @hidden
  31604. */
  31605. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31606. /**
  31607. * Register and execute a render loop. The engine can have more than one render function
  31608. * @param renderFunction defines the function to continuously execute
  31609. */
  31610. runRenderLoop(renderFunction: () => void): void;
  31611. /**
  31612. * Clear the current render buffer or the current render target (if any is set up)
  31613. * @param color defines the color to use
  31614. * @param backBuffer defines if the back buffer must be cleared
  31615. * @param depth defines if the depth buffer must be cleared
  31616. * @param stencil defines if the stencil buffer must be cleared
  31617. */
  31618. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31619. private _viewportCached;
  31620. /** @hidden */
  31621. _viewport(x: number, y: number, width: number, height: number): void;
  31622. /**
  31623. * Set the WebGL's viewport
  31624. * @param viewport defines the viewport element to be used
  31625. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31626. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31627. */
  31628. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31629. /**
  31630. * Begin a new frame
  31631. */
  31632. beginFrame(): void;
  31633. /**
  31634. * Enf the current frame
  31635. */
  31636. endFrame(): void;
  31637. /**
  31638. * Resize the view according to the canvas' size
  31639. */
  31640. resize(): void;
  31641. /**
  31642. * Force a specific size of the canvas
  31643. * @param width defines the new canvas' width
  31644. * @param height defines the new canvas' height
  31645. */
  31646. setSize(width: number, height: number): void;
  31647. /**
  31648. * Binds the frame buffer to the specified texture.
  31649. * @param texture The texture to render to or null for the default canvas
  31650. * @param faceIndex The face of the texture to render to in case of cube texture
  31651. * @param requiredWidth The width of the target to render to
  31652. * @param requiredHeight The height of the target to render to
  31653. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31654. * @param lodLevel defines the lod level to bind to the frame buffer
  31655. * @param layer defines the 2d array index to bind to frame buffer to
  31656. */
  31657. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31658. /** @hidden */
  31659. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31660. /**
  31661. * Unbind the current render target texture from the webGL context
  31662. * @param texture defines the render target texture to unbind
  31663. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31664. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31665. */
  31666. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31667. /**
  31668. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31669. */
  31670. flushFramebuffer(): void;
  31671. /**
  31672. * Unbind the current render target and bind the default framebuffer
  31673. */
  31674. restoreDefaultFramebuffer(): void;
  31675. /** @hidden */
  31676. protected _resetVertexBufferBinding(): void;
  31677. /**
  31678. * Creates a vertex buffer
  31679. * @param data the data for the vertex buffer
  31680. * @returns the new WebGL static buffer
  31681. */
  31682. createVertexBuffer(data: DataArray): DataBuffer;
  31683. private _createVertexBuffer;
  31684. /**
  31685. * Creates a dynamic vertex buffer
  31686. * @param data the data for the dynamic vertex buffer
  31687. * @returns the new WebGL dynamic buffer
  31688. */
  31689. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31690. protected _resetIndexBufferBinding(): void;
  31691. /**
  31692. * Creates a new index buffer
  31693. * @param indices defines the content of the index buffer
  31694. * @param updatable defines if the index buffer must be updatable
  31695. * @returns a new webGL buffer
  31696. */
  31697. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31698. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31699. /**
  31700. * Bind a webGL buffer to the webGL context
  31701. * @param buffer defines the buffer to bind
  31702. */
  31703. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31704. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31705. private bindBuffer;
  31706. /**
  31707. * update the bound buffer with the given data
  31708. * @param data defines the data to update
  31709. */
  31710. updateArrayBuffer(data: Float32Array): void;
  31711. private _vertexAttribPointer;
  31712. /** @hidden */
  31713. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31714. private _bindVertexBuffersAttributes;
  31715. /**
  31716. * Records a vertex array object
  31717. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31718. * @param vertexBuffers defines the list of vertex buffers to store
  31719. * @param indexBuffer defines the index buffer to store
  31720. * @param effect defines the effect to store
  31721. * @returns the new vertex array object
  31722. */
  31723. recordVertexArrayObject(vertexBuffers: {
  31724. [key: string]: VertexBuffer;
  31725. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31726. /**
  31727. * Bind a specific vertex array object
  31728. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31729. * @param vertexArrayObject defines the vertex array object to bind
  31730. * @param indexBuffer defines the index buffer to bind
  31731. */
  31732. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31733. /**
  31734. * Bind webGl buffers directly to the webGL context
  31735. * @param vertexBuffer defines the vertex buffer to bind
  31736. * @param indexBuffer defines the index buffer to bind
  31737. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31738. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31739. * @param effect defines the effect associated with the vertex buffer
  31740. */
  31741. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31742. private _unbindVertexArrayObject;
  31743. /**
  31744. * Bind a list of vertex buffers to the webGL context
  31745. * @param vertexBuffers defines the list of vertex buffers to bind
  31746. * @param indexBuffer defines the index buffer to bind
  31747. * @param effect defines the effect associated with the vertex buffers
  31748. */
  31749. bindBuffers(vertexBuffers: {
  31750. [key: string]: Nullable<VertexBuffer>;
  31751. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31752. /**
  31753. * Unbind all instance attributes
  31754. */
  31755. unbindInstanceAttributes(): void;
  31756. /**
  31757. * Release and free the memory of a vertex array object
  31758. * @param vao defines the vertex array object to delete
  31759. */
  31760. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31761. /** @hidden */
  31762. _releaseBuffer(buffer: DataBuffer): boolean;
  31763. protected _deleteBuffer(buffer: DataBuffer): void;
  31764. /**
  31765. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31766. * @param instancesBuffer defines the webGL buffer to update and bind
  31767. * @param data defines the data to store in the buffer
  31768. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31769. */
  31770. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31771. /**
  31772. * Bind the content of a webGL buffer used with instantiation
  31773. * @param instancesBuffer defines the webGL buffer to bind
  31774. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31775. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31776. */
  31777. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31778. /**
  31779. * Disable the instance attribute corresponding to the name in parameter
  31780. * @param name defines the name of the attribute to disable
  31781. */
  31782. disableInstanceAttributeByName(name: string): void;
  31783. /**
  31784. * Disable the instance attribute corresponding to the location in parameter
  31785. * @param attributeLocation defines the attribute location of the attribute to disable
  31786. */
  31787. disableInstanceAttribute(attributeLocation: number): void;
  31788. /**
  31789. * Disable the attribute corresponding to the location in parameter
  31790. * @param attributeLocation defines the attribute location of the attribute to disable
  31791. */
  31792. disableAttributeByIndex(attributeLocation: number): void;
  31793. /**
  31794. * Send a draw order
  31795. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31796. * @param indexStart defines the starting index
  31797. * @param indexCount defines the number of index to draw
  31798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31799. */
  31800. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31801. /**
  31802. * Draw a list of points
  31803. * @param verticesStart defines the index of first vertex to draw
  31804. * @param verticesCount defines the count of vertices to draw
  31805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31806. */
  31807. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31808. /**
  31809. * Draw a list of unindexed primitives
  31810. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31811. * @param verticesStart defines the index of first vertex to draw
  31812. * @param verticesCount defines the count of vertices to draw
  31813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31814. */
  31815. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31816. /**
  31817. * Draw a list of indexed primitives
  31818. * @param fillMode defines the primitive to use
  31819. * @param indexStart defines the starting index
  31820. * @param indexCount defines the number of index to draw
  31821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31822. */
  31823. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31824. /**
  31825. * Draw a list of unindexed primitives
  31826. * @param fillMode defines the primitive to use
  31827. * @param verticesStart defines the index of first vertex to draw
  31828. * @param verticesCount defines the count of vertices to draw
  31829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31830. */
  31831. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31832. private _drawMode;
  31833. /** @hidden */
  31834. protected _reportDrawCall(): void;
  31835. /** @hidden */
  31836. _releaseEffect(effect: Effect): void;
  31837. /** @hidden */
  31838. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31839. /**
  31840. * Create a new effect (used to store vertex/fragment shaders)
  31841. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31842. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31843. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31844. * @param samplers defines an array of string used to represent textures
  31845. * @param defines defines the string containing the defines to use to compile the shaders
  31846. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31847. * @param onCompiled defines a function to call when the effect creation is successful
  31848. * @param onError defines a function to call when the effect creation has failed
  31849. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31850. * @returns the new Effect
  31851. */
  31852. 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;
  31853. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31854. private _compileShader;
  31855. private _compileRawShader;
  31856. /** @hidden */
  31857. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31858. /**
  31859. * Directly creates a webGL program
  31860. * @param pipelineContext defines the pipeline context to attach to
  31861. * @param vertexCode defines the vertex shader code to use
  31862. * @param fragmentCode defines the fragment shader code to use
  31863. * @param context defines the webGL context to use (if not set, the current one will be used)
  31864. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31865. * @returns the new webGL program
  31866. */
  31867. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31868. /**
  31869. * Creates a webGL program
  31870. * @param pipelineContext defines the pipeline context to attach to
  31871. * @param vertexCode defines the vertex shader code to use
  31872. * @param fragmentCode defines the fragment shader code to use
  31873. * @param defines defines the string containing the defines to use to compile the shaders
  31874. * @param context defines the webGL context to use (if not set, the current one will be used)
  31875. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31876. * @returns the new webGL program
  31877. */
  31878. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31879. /**
  31880. * Creates a new pipeline context
  31881. * @returns the new pipeline
  31882. */
  31883. createPipelineContext(): IPipelineContext;
  31884. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31885. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31886. /** @hidden */
  31887. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31888. /** @hidden */
  31889. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31890. /** @hidden */
  31891. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31892. /**
  31893. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31894. * @param pipelineContext defines the pipeline context to use
  31895. * @param uniformsNames defines the list of uniform names
  31896. * @returns an array of webGL uniform locations
  31897. */
  31898. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31899. /**
  31900. * Gets the lsit of active attributes for a given webGL program
  31901. * @param pipelineContext defines the pipeline context to use
  31902. * @param attributesNames defines the list of attribute names to get
  31903. * @returns an array of indices indicating the offset of each attribute
  31904. */
  31905. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31906. /**
  31907. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31908. * @param effect defines the effect to activate
  31909. */
  31910. enableEffect(effect: Nullable<Effect>): void;
  31911. /**
  31912. * Set the value of an uniform to a number (int)
  31913. * @param uniform defines the webGL uniform location where to store the value
  31914. * @param value defines the int number to store
  31915. */
  31916. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31917. /**
  31918. * Set the value of an uniform to an array of int32
  31919. * @param uniform defines the webGL uniform location where to store the value
  31920. * @param array defines the array of int32 to store
  31921. */
  31922. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31923. /**
  31924. * Set the value of an uniform to an array of int32 (stored as vec2)
  31925. * @param uniform defines the webGL uniform location where to store the value
  31926. * @param array defines the array of int32 to store
  31927. */
  31928. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31929. /**
  31930. * Set the value of an uniform to an array of int32 (stored as vec3)
  31931. * @param uniform defines the webGL uniform location where to store the value
  31932. * @param array defines the array of int32 to store
  31933. */
  31934. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31935. /**
  31936. * Set the value of an uniform to an array of int32 (stored as vec4)
  31937. * @param uniform defines the webGL uniform location where to store the value
  31938. * @param array defines the array of int32 to store
  31939. */
  31940. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31941. /**
  31942. * Set the value of an uniform to an array of number
  31943. * @param uniform defines the webGL uniform location where to store the value
  31944. * @param array defines the array of number to store
  31945. */
  31946. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31947. /**
  31948. * Set the value of an uniform to an array of number (stored as vec2)
  31949. * @param uniform defines the webGL uniform location where to store the value
  31950. * @param array defines the array of number to store
  31951. */
  31952. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31953. /**
  31954. * Set the value of an uniform to an array of number (stored as vec3)
  31955. * @param uniform defines the webGL uniform location where to store the value
  31956. * @param array defines the array of number to store
  31957. */
  31958. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31959. /**
  31960. * Set the value of an uniform to an array of number (stored as vec4)
  31961. * @param uniform defines the webGL uniform location where to store the value
  31962. * @param array defines the array of number to store
  31963. */
  31964. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31965. /**
  31966. * Set the value of an uniform to an array of float32 (stored as matrices)
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param matrices defines the array of float32 to store
  31969. */
  31970. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31971. /**
  31972. * Set the value of an uniform to a matrix (3x3)
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31975. */
  31976. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31977. /**
  31978. * Set the value of an uniform to a matrix (2x2)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31981. */
  31982. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31983. /**
  31984. * Set the value of an uniform to a number (float)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param value defines the float number to store
  31987. */
  31988. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31989. /**
  31990. * Set the value of an uniform to a vec2
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param x defines the 1st component of the value
  31993. * @param y defines the 2nd component of the value
  31994. */
  31995. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31996. /**
  31997. * Set the value of an uniform to a vec3
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param x defines the 1st component of the value
  32000. * @param y defines the 2nd component of the value
  32001. * @param z defines the 3rd component of the value
  32002. */
  32003. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32004. /**
  32005. * Set the value of an uniform to a vec4
  32006. * @param uniform defines the webGL uniform location where to store the value
  32007. * @param x defines the 1st component of the value
  32008. * @param y defines the 2nd component of the value
  32009. * @param z defines the 3rd component of the value
  32010. * @param w defines the 4th component of the value
  32011. */
  32012. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32013. /**
  32014. * Apply all cached states (depth, culling, stencil and alpha)
  32015. */
  32016. applyStates(): void;
  32017. /**
  32018. * Enable or disable color writing
  32019. * @param enable defines the state to set
  32020. */
  32021. setColorWrite(enable: boolean): void;
  32022. /**
  32023. * Gets a boolean indicating if color writing is enabled
  32024. * @returns the current color writing state
  32025. */
  32026. getColorWrite(): boolean;
  32027. /**
  32028. * Gets the depth culling state manager
  32029. */
  32030. get depthCullingState(): DepthCullingState;
  32031. /**
  32032. * Gets the alpha state manager
  32033. */
  32034. get alphaState(): AlphaState;
  32035. /**
  32036. * Gets the stencil state manager
  32037. */
  32038. get stencilState(): StencilState;
  32039. /**
  32040. * Clears the list of texture accessible through engine.
  32041. * This can help preventing texture load conflict due to name collision.
  32042. */
  32043. clearInternalTexturesCache(): void;
  32044. /**
  32045. * Force the entire cache to be cleared
  32046. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32047. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32048. */
  32049. wipeCaches(bruteForce?: boolean): void;
  32050. /** @hidden */
  32051. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32052. min: number;
  32053. mag: number;
  32054. };
  32055. /** @hidden */
  32056. _createTexture(): WebGLTexture;
  32057. /**
  32058. * Usually called from Texture.ts.
  32059. * Passed information to create a WebGLTexture
  32060. * @param url defines a value which contains one of the following:
  32061. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32062. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32063. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32064. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32065. * @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)
  32066. * @param scene needed for loading to the correct scene
  32067. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32068. * @param onLoad optional callback to be called upon successful completion
  32069. * @param onError optional callback to be called upon failure
  32070. * @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
  32071. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32072. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32073. * @param forcedExtension defines the extension to use to pick the right loader
  32074. * @param mimeType defines an optional mime type
  32075. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32076. */
  32077. 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;
  32078. /**
  32079. * Loads an image as an HTMLImageElement.
  32080. * @param input url string, ArrayBuffer, or Blob to load
  32081. * @param onLoad callback called when the image successfully loads
  32082. * @param onError callback called when the image fails to load
  32083. * @param offlineProvider offline provider for caching
  32084. * @param mimeType optional mime type
  32085. * @returns the HTMLImageElement of the loaded image
  32086. * @hidden
  32087. */
  32088. 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>;
  32089. /**
  32090. * @hidden
  32091. */
  32092. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32093. /**
  32094. * Creates a raw texture
  32095. * @param data defines the data to store in the texture
  32096. * @param width defines the width of the texture
  32097. * @param height defines the height of the texture
  32098. * @param format defines the format of the data
  32099. * @param generateMipMaps defines if the engine should generate the mip levels
  32100. * @param invertY defines if data must be stored with Y axis inverted
  32101. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32102. * @param compression defines the compression used (null by default)
  32103. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32104. * @returns the raw texture inside an InternalTexture
  32105. */
  32106. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32107. /**
  32108. * Creates a new raw cube texture
  32109. * @param data defines the array of data to use to create each face
  32110. * @param size defines the size of the textures
  32111. * @param format defines the format of the data
  32112. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32113. * @param generateMipMaps defines if the engine should generate the mip levels
  32114. * @param invertY defines if data must be stored with Y axis inverted
  32115. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32116. * @param compression defines the compression used (null by default)
  32117. * @returns the cube texture as an InternalTexture
  32118. */
  32119. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32120. /**
  32121. * Creates a new raw 3D texture
  32122. * @param data defines the data used to create the texture
  32123. * @param width defines the width of the texture
  32124. * @param height defines the height of the texture
  32125. * @param depth defines the depth of the texture
  32126. * @param format defines the format of the texture
  32127. * @param generateMipMaps defines if the engine must generate mip levels
  32128. * @param invertY defines if data must be stored with Y axis inverted
  32129. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32130. * @param compression defines the compressed used (can be null)
  32131. * @param textureType defines the compressed used (can be null)
  32132. * @returns a new raw 3D texture (stored in an InternalTexture)
  32133. */
  32134. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32135. /**
  32136. * Creates a new raw 2D array texture
  32137. * @param data defines the data used to create the texture
  32138. * @param width defines the width of the texture
  32139. * @param height defines the height of the texture
  32140. * @param depth defines the number of layers of the texture
  32141. * @param format defines the format of the texture
  32142. * @param generateMipMaps defines if the engine must generate mip levels
  32143. * @param invertY defines if data must be stored with Y axis inverted
  32144. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32145. * @param compression defines the compressed used (can be null)
  32146. * @param textureType defines the compressed used (can be null)
  32147. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32148. */
  32149. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32150. private _unpackFlipYCached;
  32151. /**
  32152. * In case you are sharing the context with other applications, it might
  32153. * be interested to not cache the unpack flip y state to ensure a consistent
  32154. * value would be set.
  32155. */
  32156. enableUnpackFlipYCached: boolean;
  32157. /** @hidden */
  32158. _unpackFlipY(value: boolean): void;
  32159. /** @hidden */
  32160. _getUnpackAlignement(): number;
  32161. private _getTextureTarget;
  32162. /**
  32163. * Update the sampling mode of a given texture
  32164. * @param samplingMode defines the required sampling mode
  32165. * @param texture defines the texture to update
  32166. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32167. */
  32168. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32169. /**
  32170. * Update the sampling mode of a given texture
  32171. * @param texture defines the texture to update
  32172. * @param wrapU defines the texture wrap mode of the u coordinates
  32173. * @param wrapV defines the texture wrap mode of the v coordinates
  32174. * @param wrapR defines the texture wrap mode of the r coordinates
  32175. */
  32176. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32177. /** @hidden */
  32178. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32179. width: number;
  32180. height: number;
  32181. layers?: number;
  32182. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32183. /** @hidden */
  32184. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32185. /** @hidden */
  32186. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32187. /**
  32188. * Update a portion of an internal texture
  32189. * @param texture defines the texture to update
  32190. * @param imageData defines the data to store into the texture
  32191. * @param xOffset defines the x coordinates of the update rectangle
  32192. * @param yOffset defines the y coordinates of the update rectangle
  32193. * @param width defines the width of the update rectangle
  32194. * @param height defines the height of the update rectangle
  32195. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32196. * @param lod defines the lod level to update (0 by default)
  32197. */
  32198. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32199. /** @hidden */
  32200. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32201. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32202. private _prepareWebGLTexture;
  32203. /** @hidden */
  32204. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32205. private _getDepthStencilBuffer;
  32206. /** @hidden */
  32207. _releaseFramebufferObjects(texture: InternalTexture): void;
  32208. /** @hidden */
  32209. _releaseTexture(texture: InternalTexture): void;
  32210. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32211. protected _setProgram(program: WebGLProgram): void;
  32212. protected _boundUniforms: {
  32213. [key: number]: WebGLUniformLocation;
  32214. };
  32215. /**
  32216. * Binds an effect to the webGL context
  32217. * @param effect defines the effect to bind
  32218. */
  32219. bindSamplers(effect: Effect): void;
  32220. private _activateCurrentTexture;
  32221. /** @hidden */
  32222. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32223. /** @hidden */
  32224. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32225. /**
  32226. * Unbind all textures from the webGL context
  32227. */
  32228. unbindAllTextures(): void;
  32229. /**
  32230. * Sets a texture to the according uniform.
  32231. * @param channel The texture channel
  32232. * @param uniform The uniform to set
  32233. * @param texture The texture to apply
  32234. */
  32235. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32236. private _bindSamplerUniformToChannel;
  32237. private _getTextureWrapMode;
  32238. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32239. /**
  32240. * Sets an array of texture to the webGL context
  32241. * @param channel defines the channel where the texture array must be set
  32242. * @param uniform defines the associated uniform location
  32243. * @param textures defines the array of textures to bind
  32244. */
  32245. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32246. /** @hidden */
  32247. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32248. private _setTextureParameterFloat;
  32249. private _setTextureParameterInteger;
  32250. /**
  32251. * Unbind all vertex attributes from the webGL context
  32252. */
  32253. unbindAllAttributes(): void;
  32254. /**
  32255. * 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
  32256. */
  32257. releaseEffects(): void;
  32258. /**
  32259. * Dispose and release all associated resources
  32260. */
  32261. dispose(): void;
  32262. /**
  32263. * Attach a new callback raised when context lost event is fired
  32264. * @param callback defines the callback to call
  32265. */
  32266. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32267. /**
  32268. * Attach a new callback raised when context restored event is fired
  32269. * @param callback defines the callback to call
  32270. */
  32271. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32272. /**
  32273. * Get the current error code of the webGL context
  32274. * @returns the error code
  32275. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32276. */
  32277. getError(): number;
  32278. private _canRenderToFloatFramebuffer;
  32279. private _canRenderToHalfFloatFramebuffer;
  32280. private _canRenderToFramebuffer;
  32281. /** @hidden */
  32282. _getWebGLTextureType(type: number): number;
  32283. /** @hidden */
  32284. _getInternalFormat(format: number): number;
  32285. /** @hidden */
  32286. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32287. /** @hidden */
  32288. _getRGBAMultiSampleBufferFormat(type: number): number;
  32289. /** @hidden */
  32290. _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;
  32291. /**
  32292. * Loads a file from a url
  32293. * @param url url to load
  32294. * @param onSuccess callback called when the file successfully loads
  32295. * @param onProgress callback called while file is loading (if the server supports this mode)
  32296. * @param offlineProvider defines the offline provider for caching
  32297. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32298. * @param onError callback called when the file fails to load
  32299. * @returns a file request object
  32300. * @hidden
  32301. */
  32302. 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;
  32303. /**
  32304. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32305. * @param x defines the x coordinate of the rectangle where pixels must be read
  32306. * @param y defines the y coordinate of the rectangle where pixels must be read
  32307. * @param width defines the width of the rectangle where pixels must be read
  32308. * @param height defines the height of the rectangle where pixels must be read
  32309. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32310. * @returns a Uint8Array containing RGBA colors
  32311. */
  32312. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32313. private static _isSupported;
  32314. /**
  32315. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32316. * @returns true if the engine can be created
  32317. * @ignorenaming
  32318. */
  32319. static isSupported(): boolean;
  32320. /**
  32321. * Find the next highest power of two.
  32322. * @param x Number to start search from.
  32323. * @return Next highest power of two.
  32324. */
  32325. static CeilingPOT(x: number): number;
  32326. /**
  32327. * Find the next lowest power of two.
  32328. * @param x Number to start search from.
  32329. * @return Next lowest power of two.
  32330. */
  32331. static FloorPOT(x: number): number;
  32332. /**
  32333. * Find the nearest power of two.
  32334. * @param x Number to start search from.
  32335. * @return Next nearest power of two.
  32336. */
  32337. static NearestPOT(x: number): number;
  32338. /**
  32339. * Get the closest exponent of two
  32340. * @param value defines the value to approximate
  32341. * @param max defines the maximum value to return
  32342. * @param mode defines how to define the closest value
  32343. * @returns closest exponent of two of the given value
  32344. */
  32345. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32346. /**
  32347. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32348. * @param func - the function to be called
  32349. * @param requester - the object that will request the next frame. Falls back to window.
  32350. * @returns frame number
  32351. */
  32352. static QueueNewFrame(func: () => void, requester?: any): number;
  32353. /**
  32354. * Gets host document
  32355. * @returns the host document object
  32356. */
  32357. getHostDocument(): Nullable<Document>;
  32358. }
  32359. }
  32360. declare module BABYLON {
  32361. /**
  32362. * Class representing spherical harmonics coefficients to the 3rd degree
  32363. */
  32364. export class SphericalHarmonics {
  32365. /**
  32366. * Defines whether or not the harmonics have been prescaled for rendering.
  32367. */
  32368. preScaled: boolean;
  32369. /**
  32370. * The l0,0 coefficients of the spherical harmonics
  32371. */
  32372. l00: Vector3;
  32373. /**
  32374. * The l1,-1 coefficients of the spherical harmonics
  32375. */
  32376. l1_1: Vector3;
  32377. /**
  32378. * The l1,0 coefficients of the spherical harmonics
  32379. */
  32380. l10: Vector3;
  32381. /**
  32382. * The l1,1 coefficients of the spherical harmonics
  32383. */
  32384. l11: Vector3;
  32385. /**
  32386. * The l2,-2 coefficients of the spherical harmonics
  32387. */
  32388. l2_2: Vector3;
  32389. /**
  32390. * The l2,-1 coefficients of the spherical harmonics
  32391. */
  32392. l2_1: Vector3;
  32393. /**
  32394. * The l2,0 coefficients of the spherical harmonics
  32395. */
  32396. l20: Vector3;
  32397. /**
  32398. * The l2,1 coefficients of the spherical harmonics
  32399. */
  32400. l21: Vector3;
  32401. /**
  32402. * The l2,2 coefficients of the spherical harmonics
  32403. */
  32404. l22: Vector3;
  32405. /**
  32406. * Adds a light to the spherical harmonics
  32407. * @param direction the direction of the light
  32408. * @param color the color of the light
  32409. * @param deltaSolidAngle the delta solid angle of the light
  32410. */
  32411. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32412. /**
  32413. * Scales the spherical harmonics by the given amount
  32414. * @param scale the amount to scale
  32415. */
  32416. scaleInPlace(scale: number): void;
  32417. /**
  32418. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32419. *
  32420. * ```
  32421. * E_lm = A_l * L_lm
  32422. * ```
  32423. *
  32424. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32425. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32426. * the scaling factors are given in equation 9.
  32427. */
  32428. convertIncidentRadianceToIrradiance(): void;
  32429. /**
  32430. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32431. *
  32432. * ```
  32433. * L = (1/pi) * E * rho
  32434. * ```
  32435. *
  32436. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32437. */
  32438. convertIrradianceToLambertianRadiance(): void;
  32439. /**
  32440. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32441. * required operations at run time.
  32442. *
  32443. * This is simply done by scaling back the SH with Ylm constants parameter.
  32444. * The trigonometric part being applied by the shader at run time.
  32445. */
  32446. preScaleForRendering(): void;
  32447. /**
  32448. * Constructs a spherical harmonics from an array.
  32449. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32450. * @returns the spherical harmonics
  32451. */
  32452. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32453. /**
  32454. * Gets the spherical harmonics from polynomial
  32455. * @param polynomial the spherical polynomial
  32456. * @returns the spherical harmonics
  32457. */
  32458. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32459. }
  32460. /**
  32461. * Class representing spherical polynomial coefficients to the 3rd degree
  32462. */
  32463. export class SphericalPolynomial {
  32464. private _harmonics;
  32465. /**
  32466. * The spherical harmonics used to create the polynomials.
  32467. */
  32468. get preScaledHarmonics(): SphericalHarmonics;
  32469. /**
  32470. * The x coefficients of the spherical polynomial
  32471. */
  32472. x: Vector3;
  32473. /**
  32474. * The y coefficients of the spherical polynomial
  32475. */
  32476. y: Vector3;
  32477. /**
  32478. * The z coefficients of the spherical polynomial
  32479. */
  32480. z: Vector3;
  32481. /**
  32482. * The xx coefficients of the spherical polynomial
  32483. */
  32484. xx: Vector3;
  32485. /**
  32486. * The yy coefficients of the spherical polynomial
  32487. */
  32488. yy: Vector3;
  32489. /**
  32490. * The zz coefficients of the spherical polynomial
  32491. */
  32492. zz: Vector3;
  32493. /**
  32494. * The xy coefficients of the spherical polynomial
  32495. */
  32496. xy: Vector3;
  32497. /**
  32498. * The yz coefficients of the spherical polynomial
  32499. */
  32500. yz: Vector3;
  32501. /**
  32502. * The zx coefficients of the spherical polynomial
  32503. */
  32504. zx: Vector3;
  32505. /**
  32506. * Adds an ambient color to the spherical polynomial
  32507. * @param color the color to add
  32508. */
  32509. addAmbient(color: Color3): void;
  32510. /**
  32511. * Scales the spherical polynomial by the given amount
  32512. * @param scale the amount to scale
  32513. */
  32514. scaleInPlace(scale: number): void;
  32515. /**
  32516. * Gets the spherical polynomial from harmonics
  32517. * @param harmonics the spherical harmonics
  32518. * @returns the spherical polynomial
  32519. */
  32520. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32521. /**
  32522. * Constructs a spherical polynomial from an array.
  32523. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32524. * @returns the spherical polynomial
  32525. */
  32526. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32527. }
  32528. }
  32529. declare module BABYLON {
  32530. /**
  32531. * Defines the source of the internal texture
  32532. */
  32533. export enum InternalTextureSource {
  32534. /**
  32535. * The source of the texture data is unknown
  32536. */
  32537. Unknown = 0,
  32538. /**
  32539. * Texture data comes from an URL
  32540. */
  32541. Url = 1,
  32542. /**
  32543. * Texture data is only used for temporary storage
  32544. */
  32545. Temp = 2,
  32546. /**
  32547. * Texture data comes from raw data (ArrayBuffer)
  32548. */
  32549. Raw = 3,
  32550. /**
  32551. * Texture content is dynamic (video or dynamic texture)
  32552. */
  32553. Dynamic = 4,
  32554. /**
  32555. * Texture content is generated by rendering to it
  32556. */
  32557. RenderTarget = 5,
  32558. /**
  32559. * Texture content is part of a multi render target process
  32560. */
  32561. MultiRenderTarget = 6,
  32562. /**
  32563. * Texture data comes from a cube data file
  32564. */
  32565. Cube = 7,
  32566. /**
  32567. * Texture data comes from a raw cube data
  32568. */
  32569. CubeRaw = 8,
  32570. /**
  32571. * Texture data come from a prefiltered cube data file
  32572. */
  32573. CubePrefiltered = 9,
  32574. /**
  32575. * Texture content is raw 3D data
  32576. */
  32577. Raw3D = 10,
  32578. /**
  32579. * Texture content is raw 2D array data
  32580. */
  32581. Raw2DArray = 11,
  32582. /**
  32583. * Texture content is a depth texture
  32584. */
  32585. Depth = 12,
  32586. /**
  32587. * Texture data comes from a raw cube data encoded with RGBD
  32588. */
  32589. CubeRawRGBD = 13
  32590. }
  32591. /**
  32592. * Class used to store data associated with WebGL texture data for the engine
  32593. * This class should not be used directly
  32594. */
  32595. export class InternalTexture {
  32596. /** @hidden */
  32597. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32598. /**
  32599. * Defines if the texture is ready
  32600. */
  32601. isReady: boolean;
  32602. /**
  32603. * Defines if the texture is a cube texture
  32604. */
  32605. isCube: boolean;
  32606. /**
  32607. * Defines if the texture contains 3D data
  32608. */
  32609. is3D: boolean;
  32610. /**
  32611. * Defines if the texture contains 2D array data
  32612. */
  32613. is2DArray: boolean;
  32614. /**
  32615. * Defines if the texture contains multiview data
  32616. */
  32617. isMultiview: boolean;
  32618. /**
  32619. * Gets the URL used to load this texture
  32620. */
  32621. url: string;
  32622. /**
  32623. * Gets the sampling mode of the texture
  32624. */
  32625. samplingMode: number;
  32626. /**
  32627. * Gets a boolean indicating if the texture needs mipmaps generation
  32628. */
  32629. generateMipMaps: boolean;
  32630. /**
  32631. * Gets the number of samples used by the texture (WebGL2+ only)
  32632. */
  32633. samples: number;
  32634. /**
  32635. * Gets the type of the texture (int, float...)
  32636. */
  32637. type: number;
  32638. /**
  32639. * Gets the format of the texture (RGB, RGBA...)
  32640. */
  32641. format: number;
  32642. /**
  32643. * Observable called when the texture is loaded
  32644. */
  32645. onLoadedObservable: Observable<InternalTexture>;
  32646. /**
  32647. * Gets the width of the texture
  32648. */
  32649. width: number;
  32650. /**
  32651. * Gets the height of the texture
  32652. */
  32653. height: number;
  32654. /**
  32655. * Gets the depth of the texture
  32656. */
  32657. depth: number;
  32658. /**
  32659. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32660. */
  32661. baseWidth: number;
  32662. /**
  32663. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32664. */
  32665. baseHeight: number;
  32666. /**
  32667. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32668. */
  32669. baseDepth: number;
  32670. /**
  32671. * Gets a boolean indicating if the texture is inverted on Y axis
  32672. */
  32673. invertY: boolean;
  32674. /** @hidden */
  32675. _invertVScale: boolean;
  32676. /** @hidden */
  32677. _associatedChannel: number;
  32678. /** @hidden */
  32679. _source: InternalTextureSource;
  32680. /** @hidden */
  32681. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32682. /** @hidden */
  32683. _bufferView: Nullable<ArrayBufferView>;
  32684. /** @hidden */
  32685. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32686. /** @hidden */
  32687. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32688. /** @hidden */
  32689. _size: number;
  32690. /** @hidden */
  32691. _extension: string;
  32692. /** @hidden */
  32693. _files: Nullable<string[]>;
  32694. /** @hidden */
  32695. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32696. /** @hidden */
  32697. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32698. /** @hidden */
  32699. _framebuffer: Nullable<WebGLFramebuffer>;
  32700. /** @hidden */
  32701. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32702. /** @hidden */
  32703. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32704. /** @hidden */
  32705. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32706. /** @hidden */
  32707. _attachments: Nullable<number[]>;
  32708. /** @hidden */
  32709. _cachedCoordinatesMode: Nullable<number>;
  32710. /** @hidden */
  32711. _cachedWrapU: Nullable<number>;
  32712. /** @hidden */
  32713. _cachedWrapV: Nullable<number>;
  32714. /** @hidden */
  32715. _cachedWrapR: Nullable<number>;
  32716. /** @hidden */
  32717. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32718. /** @hidden */
  32719. _isDisabled: boolean;
  32720. /** @hidden */
  32721. _compression: Nullable<string>;
  32722. /** @hidden */
  32723. _generateStencilBuffer: boolean;
  32724. /** @hidden */
  32725. _generateDepthBuffer: boolean;
  32726. /** @hidden */
  32727. _comparisonFunction: number;
  32728. /** @hidden */
  32729. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32730. /** @hidden */
  32731. _lodGenerationScale: number;
  32732. /** @hidden */
  32733. _lodGenerationOffset: number;
  32734. /** @hidden */
  32735. _depthStencilTexture: Nullable<InternalTexture>;
  32736. /** @hidden */
  32737. _colorTextureArray: Nullable<WebGLTexture>;
  32738. /** @hidden */
  32739. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32740. /** @hidden */
  32741. _lodTextureHigh: Nullable<BaseTexture>;
  32742. /** @hidden */
  32743. _lodTextureMid: Nullable<BaseTexture>;
  32744. /** @hidden */
  32745. _lodTextureLow: Nullable<BaseTexture>;
  32746. /** @hidden */
  32747. _isRGBD: boolean;
  32748. /** @hidden */
  32749. _linearSpecularLOD: boolean;
  32750. /** @hidden */
  32751. _irradianceTexture: Nullable<BaseTexture>;
  32752. /** @hidden */
  32753. _webGLTexture: Nullable<WebGLTexture>;
  32754. /** @hidden */
  32755. _references: number;
  32756. private _engine;
  32757. /**
  32758. * Gets the Engine the texture belongs to.
  32759. * @returns The babylon engine
  32760. */
  32761. getEngine(): ThinEngine;
  32762. /**
  32763. * Gets the data source type of the texture
  32764. */
  32765. get source(): InternalTextureSource;
  32766. /**
  32767. * Creates a new InternalTexture
  32768. * @param engine defines the engine to use
  32769. * @param source defines the type of data that will be used
  32770. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32771. */
  32772. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32773. /**
  32774. * Increments the number of references (ie. the number of Texture that point to it)
  32775. */
  32776. incrementReferences(): void;
  32777. /**
  32778. * Change the size of the texture (not the size of the content)
  32779. * @param width defines the new width
  32780. * @param height defines the new height
  32781. * @param depth defines the new depth (1 by default)
  32782. */
  32783. updateSize(width: int, height: int, depth?: int): void;
  32784. /** @hidden */
  32785. _rebuild(): void;
  32786. /** @hidden */
  32787. _swapAndDie(target: InternalTexture): void;
  32788. /**
  32789. * Dispose the current allocated resources
  32790. */
  32791. dispose(): void;
  32792. }
  32793. }
  32794. declare module BABYLON {
  32795. /**
  32796. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32798. */
  32799. export class Analyser {
  32800. /**
  32801. * Gets or sets the smoothing
  32802. * @ignorenaming
  32803. */
  32804. SMOOTHING: number;
  32805. /**
  32806. * Gets or sets the FFT table size
  32807. * @ignorenaming
  32808. */
  32809. FFT_SIZE: number;
  32810. /**
  32811. * Gets or sets the bar graph amplitude
  32812. * @ignorenaming
  32813. */
  32814. BARGRAPHAMPLITUDE: number;
  32815. /**
  32816. * Gets or sets the position of the debug canvas
  32817. * @ignorenaming
  32818. */
  32819. DEBUGCANVASPOS: {
  32820. x: number;
  32821. y: number;
  32822. };
  32823. /**
  32824. * Gets or sets the debug canvas size
  32825. * @ignorenaming
  32826. */
  32827. DEBUGCANVASSIZE: {
  32828. width: number;
  32829. height: number;
  32830. };
  32831. private _byteFreqs;
  32832. private _byteTime;
  32833. private _floatFreqs;
  32834. private _webAudioAnalyser;
  32835. private _debugCanvas;
  32836. private _debugCanvasContext;
  32837. private _scene;
  32838. private _registerFunc;
  32839. private _audioEngine;
  32840. /**
  32841. * Creates a new analyser
  32842. * @param scene defines hosting scene
  32843. */
  32844. constructor(scene: Scene);
  32845. /**
  32846. * Get the number of data values you will have to play with for the visualization
  32847. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32848. * @returns a number
  32849. */
  32850. getFrequencyBinCount(): number;
  32851. /**
  32852. * Gets the current frequency data as a byte array
  32853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32854. * @returns a Uint8Array
  32855. */
  32856. getByteFrequencyData(): Uint8Array;
  32857. /**
  32858. * Gets the current waveform as a byte array
  32859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32860. * @returns a Uint8Array
  32861. */
  32862. getByteTimeDomainData(): Uint8Array;
  32863. /**
  32864. * Gets the current frequency data as a float array
  32865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32866. * @returns a Float32Array
  32867. */
  32868. getFloatFrequencyData(): Float32Array;
  32869. /**
  32870. * Renders the debug canvas
  32871. */
  32872. drawDebugCanvas(): void;
  32873. /**
  32874. * Stops rendering the debug canvas and removes it
  32875. */
  32876. stopDebugCanvas(): void;
  32877. /**
  32878. * Connects two audio nodes
  32879. * @param inputAudioNode defines first node to connect
  32880. * @param outputAudioNode defines second node to connect
  32881. */
  32882. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32883. /**
  32884. * Releases all associated resources
  32885. */
  32886. dispose(): void;
  32887. }
  32888. }
  32889. declare module BABYLON {
  32890. /**
  32891. * This represents an audio engine and it is responsible
  32892. * to play, synchronize and analyse sounds throughout the application.
  32893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32894. */
  32895. export interface IAudioEngine extends IDisposable {
  32896. /**
  32897. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32898. */
  32899. readonly canUseWebAudio: boolean;
  32900. /**
  32901. * Gets the current AudioContext if available.
  32902. */
  32903. readonly audioContext: Nullable<AudioContext>;
  32904. /**
  32905. * The master gain node defines the global audio volume of your audio engine.
  32906. */
  32907. readonly masterGain: GainNode;
  32908. /**
  32909. * Gets whether or not mp3 are supported by your browser.
  32910. */
  32911. readonly isMP3supported: boolean;
  32912. /**
  32913. * Gets whether or not ogg are supported by your browser.
  32914. */
  32915. readonly isOGGsupported: boolean;
  32916. /**
  32917. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32918. * @ignoreNaming
  32919. */
  32920. WarnedWebAudioUnsupported: boolean;
  32921. /**
  32922. * Defines if the audio engine relies on a custom unlocked button.
  32923. * In this case, the embedded button will not be displayed.
  32924. */
  32925. useCustomUnlockedButton: boolean;
  32926. /**
  32927. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32928. */
  32929. readonly unlocked: boolean;
  32930. /**
  32931. * Event raised when audio has been unlocked on the browser.
  32932. */
  32933. onAudioUnlockedObservable: Observable<AudioEngine>;
  32934. /**
  32935. * Event raised when audio has been locked on the browser.
  32936. */
  32937. onAudioLockedObservable: Observable<AudioEngine>;
  32938. /**
  32939. * Flags the audio engine in Locked state.
  32940. * This happens due to new browser policies preventing audio to autoplay.
  32941. */
  32942. lock(): void;
  32943. /**
  32944. * Unlocks the audio engine once a user action has been done on the dom.
  32945. * This is helpful to resume play once browser policies have been satisfied.
  32946. */
  32947. unlock(): void;
  32948. /**
  32949. * Gets the global volume sets on the master gain.
  32950. * @returns the global volume if set or -1 otherwise
  32951. */
  32952. getGlobalVolume(): number;
  32953. /**
  32954. * Sets the global volume of your experience (sets on the master gain).
  32955. * @param newVolume Defines the new global volume of the application
  32956. */
  32957. setGlobalVolume(newVolume: number): void;
  32958. /**
  32959. * Connect the audio engine to an audio analyser allowing some amazing
  32960. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32962. * @param analyser The analyser to connect to the engine
  32963. */
  32964. connectToAnalyser(analyser: Analyser): void;
  32965. }
  32966. /**
  32967. * This represents the default audio engine used in babylon.
  32968. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32970. */
  32971. export class AudioEngine implements IAudioEngine {
  32972. private _audioContext;
  32973. private _audioContextInitialized;
  32974. private _muteButton;
  32975. private _hostElement;
  32976. /**
  32977. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32978. */
  32979. canUseWebAudio: boolean;
  32980. /**
  32981. * The master gain node defines the global audio volume of your audio engine.
  32982. */
  32983. masterGain: GainNode;
  32984. /**
  32985. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32986. * @ignoreNaming
  32987. */
  32988. WarnedWebAudioUnsupported: boolean;
  32989. /**
  32990. * Gets whether or not mp3 are supported by your browser.
  32991. */
  32992. isMP3supported: boolean;
  32993. /**
  32994. * Gets whether or not ogg are supported by your browser.
  32995. */
  32996. isOGGsupported: boolean;
  32997. /**
  32998. * Gets whether audio has been unlocked on the device.
  32999. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33000. * a user interaction has happened.
  33001. */
  33002. unlocked: boolean;
  33003. /**
  33004. * Defines if the audio engine relies on a custom unlocked button.
  33005. * In this case, the embedded button will not be displayed.
  33006. */
  33007. useCustomUnlockedButton: boolean;
  33008. /**
  33009. * Event raised when audio has been unlocked on the browser.
  33010. */
  33011. onAudioUnlockedObservable: Observable<AudioEngine>;
  33012. /**
  33013. * Event raised when audio has been locked on the browser.
  33014. */
  33015. onAudioLockedObservable: Observable<AudioEngine>;
  33016. /**
  33017. * Gets the current AudioContext if available.
  33018. */
  33019. get audioContext(): Nullable<AudioContext>;
  33020. private _connectedAnalyser;
  33021. /**
  33022. * Instantiates a new audio engine.
  33023. *
  33024. * There should be only one per page as some browsers restrict the number
  33025. * of audio contexts you can create.
  33026. * @param hostElement defines the host element where to display the mute icon if necessary
  33027. */
  33028. constructor(hostElement?: Nullable<HTMLElement>);
  33029. /**
  33030. * Flags the audio engine in Locked state.
  33031. * This happens due to new browser policies preventing audio to autoplay.
  33032. */
  33033. lock(): void;
  33034. /**
  33035. * Unlocks the audio engine once a user action has been done on the dom.
  33036. * This is helpful to resume play once browser policies have been satisfied.
  33037. */
  33038. unlock(): void;
  33039. private _resumeAudioContext;
  33040. private _initializeAudioContext;
  33041. private _tryToRun;
  33042. private _triggerRunningState;
  33043. private _triggerSuspendedState;
  33044. private _displayMuteButton;
  33045. private _moveButtonToTopLeft;
  33046. private _onResize;
  33047. private _hideMuteButton;
  33048. /**
  33049. * Destroy and release the resources associated with the audio ccontext.
  33050. */
  33051. dispose(): void;
  33052. /**
  33053. * Gets the global volume sets on the master gain.
  33054. * @returns the global volume if set or -1 otherwise
  33055. */
  33056. getGlobalVolume(): number;
  33057. /**
  33058. * Sets the global volume of your experience (sets on the master gain).
  33059. * @param newVolume Defines the new global volume of the application
  33060. */
  33061. setGlobalVolume(newVolume: number): void;
  33062. /**
  33063. * Connect the audio engine to an audio analyser allowing some amazing
  33064. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33066. * @param analyser The analyser to connect to the engine
  33067. */
  33068. connectToAnalyser(analyser: Analyser): void;
  33069. }
  33070. }
  33071. declare module BABYLON {
  33072. /**
  33073. * Interface used to present a loading screen while loading a scene
  33074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33075. */
  33076. export interface ILoadingScreen {
  33077. /**
  33078. * Function called to display the loading screen
  33079. */
  33080. displayLoadingUI: () => void;
  33081. /**
  33082. * Function called to hide the loading screen
  33083. */
  33084. hideLoadingUI: () => void;
  33085. /**
  33086. * Gets or sets the color to use for the background
  33087. */
  33088. loadingUIBackgroundColor: string;
  33089. /**
  33090. * Gets or sets the text to display while loading
  33091. */
  33092. loadingUIText: string;
  33093. }
  33094. /**
  33095. * Class used for the default loading screen
  33096. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33097. */
  33098. export class DefaultLoadingScreen implements ILoadingScreen {
  33099. private _renderingCanvas;
  33100. private _loadingText;
  33101. private _loadingDivBackgroundColor;
  33102. private _loadingDiv;
  33103. private _loadingTextDiv;
  33104. /** Gets or sets the logo url to use for the default loading screen */
  33105. static DefaultLogoUrl: string;
  33106. /** Gets or sets the spinner url to use for the default loading screen */
  33107. static DefaultSpinnerUrl: string;
  33108. /**
  33109. * Creates a new default loading screen
  33110. * @param _renderingCanvas defines the canvas used to render the scene
  33111. * @param _loadingText defines the default text to display
  33112. * @param _loadingDivBackgroundColor defines the default background color
  33113. */
  33114. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33115. /**
  33116. * Function called to display the loading screen
  33117. */
  33118. displayLoadingUI(): void;
  33119. /**
  33120. * Function called to hide the loading screen
  33121. */
  33122. hideLoadingUI(): void;
  33123. /**
  33124. * Gets or sets the text to display while loading
  33125. */
  33126. set loadingUIText(text: string);
  33127. get loadingUIText(): string;
  33128. /**
  33129. * Gets or sets the color to use for the background
  33130. */
  33131. get loadingUIBackgroundColor(): string;
  33132. set loadingUIBackgroundColor(color: string);
  33133. private _resizeLoadingUI;
  33134. }
  33135. }
  33136. declare module BABYLON {
  33137. /**
  33138. * Interface for any object that can request an animation frame
  33139. */
  33140. export interface ICustomAnimationFrameRequester {
  33141. /**
  33142. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33143. */
  33144. renderFunction?: Function;
  33145. /**
  33146. * Called to request the next frame to render to
  33147. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33148. */
  33149. requestAnimationFrame: Function;
  33150. /**
  33151. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33152. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33153. */
  33154. requestID?: number;
  33155. }
  33156. }
  33157. declare module BABYLON {
  33158. /**
  33159. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33160. */
  33161. export class PerformanceMonitor {
  33162. private _enabled;
  33163. private _rollingFrameTime;
  33164. private _lastFrameTimeMs;
  33165. /**
  33166. * constructor
  33167. * @param frameSampleSize The number of samples required to saturate the sliding window
  33168. */
  33169. constructor(frameSampleSize?: number);
  33170. /**
  33171. * Samples current frame
  33172. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33173. */
  33174. sampleFrame(timeMs?: number): void;
  33175. /**
  33176. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33177. */
  33178. get averageFrameTime(): number;
  33179. /**
  33180. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33181. */
  33182. get averageFrameTimeVariance(): number;
  33183. /**
  33184. * Returns the frame time of the most recent frame
  33185. */
  33186. get instantaneousFrameTime(): number;
  33187. /**
  33188. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33189. */
  33190. get averageFPS(): number;
  33191. /**
  33192. * Returns the average framerate in frames per second using the most recent frame time
  33193. */
  33194. get instantaneousFPS(): number;
  33195. /**
  33196. * Returns true if enough samples have been taken to completely fill the sliding window
  33197. */
  33198. get isSaturated(): boolean;
  33199. /**
  33200. * Enables contributions to the sliding window sample set
  33201. */
  33202. enable(): void;
  33203. /**
  33204. * Disables contributions to the sliding window sample set
  33205. * Samples will not be interpolated over the disabled period
  33206. */
  33207. disable(): void;
  33208. /**
  33209. * Returns true if sampling is enabled
  33210. */
  33211. get isEnabled(): boolean;
  33212. /**
  33213. * Resets performance monitor
  33214. */
  33215. reset(): void;
  33216. }
  33217. /**
  33218. * RollingAverage
  33219. *
  33220. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33221. */
  33222. export class RollingAverage {
  33223. /**
  33224. * Current average
  33225. */
  33226. average: number;
  33227. /**
  33228. * Current variance
  33229. */
  33230. variance: number;
  33231. protected _samples: Array<number>;
  33232. protected _sampleCount: number;
  33233. protected _pos: number;
  33234. protected _m2: number;
  33235. /**
  33236. * constructor
  33237. * @param length The number of samples required to saturate the sliding window
  33238. */
  33239. constructor(length: number);
  33240. /**
  33241. * Adds a sample to the sample set
  33242. * @param v The sample value
  33243. */
  33244. add(v: number): void;
  33245. /**
  33246. * Returns previously added values or null if outside of history or outside the sliding window domain
  33247. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33248. * @return Value previously recorded with add() or null if outside of range
  33249. */
  33250. history(i: number): number;
  33251. /**
  33252. * Returns true if enough samples have been taken to completely fill the sliding window
  33253. * @return true if sample-set saturated
  33254. */
  33255. isSaturated(): boolean;
  33256. /**
  33257. * Resets the rolling average (equivalent to 0 samples taken so far)
  33258. */
  33259. reset(): void;
  33260. /**
  33261. * Wraps a value around the sample range boundaries
  33262. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33263. * @return Wrapped position in sample range
  33264. */
  33265. protected _wrapPosition(i: number): number;
  33266. }
  33267. }
  33268. declare module BABYLON {
  33269. /**
  33270. * This class is used to track a performance counter which is number based.
  33271. * The user has access to many properties which give statistics of different nature.
  33272. *
  33273. * The implementer can track two kinds of Performance Counter: time and count.
  33274. * 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.
  33275. * 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.
  33276. */
  33277. export class PerfCounter {
  33278. /**
  33279. * Gets or sets a global boolean to turn on and off all the counters
  33280. */
  33281. static Enabled: boolean;
  33282. /**
  33283. * Returns the smallest value ever
  33284. */
  33285. get min(): number;
  33286. /**
  33287. * Returns the biggest value ever
  33288. */
  33289. get max(): number;
  33290. /**
  33291. * Returns the average value since the performance counter is running
  33292. */
  33293. get average(): number;
  33294. /**
  33295. * Returns the average value of the last second the counter was monitored
  33296. */
  33297. get lastSecAverage(): number;
  33298. /**
  33299. * Returns the current value
  33300. */
  33301. get current(): number;
  33302. /**
  33303. * Gets the accumulated total
  33304. */
  33305. get total(): number;
  33306. /**
  33307. * Gets the total value count
  33308. */
  33309. get count(): number;
  33310. /**
  33311. * Creates a new counter
  33312. */
  33313. constructor();
  33314. /**
  33315. * Call this method to start monitoring a new frame.
  33316. * 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.
  33317. */
  33318. fetchNewFrame(): void;
  33319. /**
  33320. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33321. * @param newCount the count value to add to the monitored count
  33322. * @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.
  33323. */
  33324. addCount(newCount: number, fetchResult: boolean): void;
  33325. /**
  33326. * Start monitoring this performance counter
  33327. */
  33328. beginMonitoring(): void;
  33329. /**
  33330. * Compute the time lapsed since the previous beginMonitoring() call.
  33331. * @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
  33332. */
  33333. endMonitoring(newFrame?: boolean): void;
  33334. private _fetchResult;
  33335. private _startMonitoringTime;
  33336. private _min;
  33337. private _max;
  33338. private _average;
  33339. private _current;
  33340. private _totalValueCount;
  33341. private _totalAccumulated;
  33342. private _lastSecAverage;
  33343. private _lastSecAccumulated;
  33344. private _lastSecTime;
  33345. private _lastSecValueCount;
  33346. }
  33347. }
  33348. declare module BABYLON {
  33349. interface ThinEngine {
  33350. /**
  33351. * Sets alpha constants used by some alpha blending modes
  33352. * @param r defines the red component
  33353. * @param g defines the green component
  33354. * @param b defines the blue component
  33355. * @param a defines the alpha component
  33356. */
  33357. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33358. /**
  33359. * Sets the current alpha mode
  33360. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33361. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33362. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33363. */
  33364. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33365. /**
  33366. * Gets the current alpha mode
  33367. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33368. * @returns the current alpha mode
  33369. */
  33370. getAlphaMode(): number;
  33371. /**
  33372. * Sets the current alpha equation
  33373. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33374. */
  33375. setAlphaEquation(equation: number): void;
  33376. /**
  33377. * Gets the current alpha equation.
  33378. * @returns the current alpha equation
  33379. */
  33380. getAlphaEquation(): number;
  33381. }
  33382. }
  33383. declare module BABYLON {
  33384. /**
  33385. * Defines the interface used by display changed events
  33386. */
  33387. export interface IDisplayChangedEventArgs {
  33388. /** Gets the vrDisplay object (if any) */
  33389. vrDisplay: Nullable<any>;
  33390. /** Gets a boolean indicating if webVR is supported */
  33391. vrSupported: boolean;
  33392. }
  33393. /**
  33394. * Defines the interface used by objects containing a viewport (like a camera)
  33395. */
  33396. interface IViewportOwnerLike {
  33397. /**
  33398. * Gets or sets the viewport
  33399. */
  33400. viewport: IViewportLike;
  33401. }
  33402. /**
  33403. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33404. */
  33405. export class Engine extends ThinEngine {
  33406. /** Defines that alpha blending is disabled */
  33407. static readonly ALPHA_DISABLE: number;
  33408. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33409. static readonly ALPHA_ADD: number;
  33410. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33411. static readonly ALPHA_COMBINE: number;
  33412. /** Defines that alpha blending to DEST - SRC * DEST */
  33413. static readonly ALPHA_SUBTRACT: number;
  33414. /** Defines that alpha blending to SRC * DEST */
  33415. static readonly ALPHA_MULTIPLY: number;
  33416. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33417. static readonly ALPHA_MAXIMIZED: number;
  33418. /** Defines that alpha blending to SRC + DEST */
  33419. static readonly ALPHA_ONEONE: number;
  33420. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33421. static readonly ALPHA_PREMULTIPLIED: number;
  33422. /**
  33423. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33424. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33425. */
  33426. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33427. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33428. static readonly ALPHA_INTERPOLATE: number;
  33429. /**
  33430. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33431. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33432. */
  33433. static readonly ALPHA_SCREENMODE: number;
  33434. /** Defines that the ressource is not delayed*/
  33435. static readonly DELAYLOADSTATE_NONE: number;
  33436. /** Defines that the ressource was successfully delay loaded */
  33437. static readonly DELAYLOADSTATE_LOADED: number;
  33438. /** Defines that the ressource is currently delay loading */
  33439. static readonly DELAYLOADSTATE_LOADING: number;
  33440. /** Defines that the ressource is delayed and has not started loading */
  33441. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33443. static readonly NEVER: number;
  33444. /** 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 */
  33445. static readonly ALWAYS: number;
  33446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33447. static readonly LESS: number;
  33448. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33449. static readonly EQUAL: number;
  33450. /** 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 */
  33451. static readonly LEQUAL: number;
  33452. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33453. static readonly GREATER: number;
  33454. /** 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 */
  33455. static readonly GEQUAL: number;
  33456. /** 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 */
  33457. static readonly NOTEQUAL: number;
  33458. /** Passed to stencilOperation to specify that stencil value must be kept */
  33459. static readonly KEEP: number;
  33460. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33461. static readonly REPLACE: number;
  33462. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33463. static readonly INCR: number;
  33464. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33465. static readonly DECR: number;
  33466. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33467. static readonly INVERT: number;
  33468. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33469. static readonly INCR_WRAP: number;
  33470. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33471. static readonly DECR_WRAP: number;
  33472. /** Texture is not repeating outside of 0..1 UVs */
  33473. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33474. /** Texture is repeating outside of 0..1 UVs */
  33475. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33476. /** Texture is repeating and mirrored */
  33477. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33478. /** ALPHA */
  33479. static readonly TEXTUREFORMAT_ALPHA: number;
  33480. /** LUMINANCE */
  33481. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33482. /** LUMINANCE_ALPHA */
  33483. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33484. /** RGB */
  33485. static readonly TEXTUREFORMAT_RGB: number;
  33486. /** RGBA */
  33487. static readonly TEXTUREFORMAT_RGBA: number;
  33488. /** RED */
  33489. static readonly TEXTUREFORMAT_RED: number;
  33490. /** RED (2nd reference) */
  33491. static readonly TEXTUREFORMAT_R: number;
  33492. /** RG */
  33493. static readonly TEXTUREFORMAT_RG: number;
  33494. /** RED_INTEGER */
  33495. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33496. /** RED_INTEGER (2nd reference) */
  33497. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33498. /** RG_INTEGER */
  33499. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33500. /** RGB_INTEGER */
  33501. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33502. /** RGBA_INTEGER */
  33503. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33504. /** UNSIGNED_BYTE */
  33505. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33506. /** UNSIGNED_BYTE (2nd reference) */
  33507. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33508. /** FLOAT */
  33509. static readonly TEXTURETYPE_FLOAT: number;
  33510. /** HALF_FLOAT */
  33511. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33512. /** BYTE */
  33513. static readonly TEXTURETYPE_BYTE: number;
  33514. /** SHORT */
  33515. static readonly TEXTURETYPE_SHORT: number;
  33516. /** UNSIGNED_SHORT */
  33517. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33518. /** INT */
  33519. static readonly TEXTURETYPE_INT: number;
  33520. /** UNSIGNED_INT */
  33521. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33522. /** UNSIGNED_SHORT_4_4_4_4 */
  33523. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33524. /** UNSIGNED_SHORT_5_5_5_1 */
  33525. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33526. /** UNSIGNED_SHORT_5_6_5 */
  33527. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33528. /** UNSIGNED_INT_2_10_10_10_REV */
  33529. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33530. /** UNSIGNED_INT_24_8 */
  33531. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33532. /** UNSIGNED_INT_10F_11F_11F_REV */
  33533. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33534. /** UNSIGNED_INT_5_9_9_9_REV */
  33535. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33536. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33537. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33538. /** nearest is mag = nearest and min = nearest and mip = linear */
  33539. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33540. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33541. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33542. /** Trilinear is mag = linear and min = linear and mip = linear */
  33543. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33544. /** nearest is mag = nearest and min = nearest and mip = linear */
  33545. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33546. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33547. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33548. /** Trilinear is mag = linear and min = linear and mip = linear */
  33549. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33550. /** mag = nearest and min = nearest and mip = nearest */
  33551. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33552. /** mag = nearest and min = linear and mip = nearest */
  33553. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33554. /** mag = nearest and min = linear and mip = linear */
  33555. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33556. /** mag = nearest and min = linear and mip = none */
  33557. static readonly TEXTURE_NEAREST_LINEAR: number;
  33558. /** mag = nearest and min = nearest and mip = none */
  33559. static readonly TEXTURE_NEAREST_NEAREST: number;
  33560. /** mag = linear and min = nearest and mip = nearest */
  33561. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33562. /** mag = linear and min = nearest and mip = linear */
  33563. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33564. /** mag = linear and min = linear and mip = none */
  33565. static readonly TEXTURE_LINEAR_LINEAR: number;
  33566. /** mag = linear and min = nearest and mip = none */
  33567. static readonly TEXTURE_LINEAR_NEAREST: number;
  33568. /** Explicit coordinates mode */
  33569. static readonly TEXTURE_EXPLICIT_MODE: number;
  33570. /** Spherical coordinates mode */
  33571. static readonly TEXTURE_SPHERICAL_MODE: number;
  33572. /** Planar coordinates mode */
  33573. static readonly TEXTURE_PLANAR_MODE: number;
  33574. /** Cubic coordinates mode */
  33575. static readonly TEXTURE_CUBIC_MODE: number;
  33576. /** Projection coordinates mode */
  33577. static readonly TEXTURE_PROJECTION_MODE: number;
  33578. /** Skybox coordinates mode */
  33579. static readonly TEXTURE_SKYBOX_MODE: number;
  33580. /** Inverse Cubic coordinates mode */
  33581. static readonly TEXTURE_INVCUBIC_MODE: number;
  33582. /** Equirectangular coordinates mode */
  33583. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33584. /** Equirectangular Fixed coordinates mode */
  33585. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33586. /** Equirectangular Fixed Mirrored coordinates mode */
  33587. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33588. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33589. static readonly SCALEMODE_FLOOR: number;
  33590. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33591. static readonly SCALEMODE_NEAREST: number;
  33592. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33593. static readonly SCALEMODE_CEILING: number;
  33594. /**
  33595. * Returns the current npm package of the sdk
  33596. */
  33597. static get NpmPackage(): string;
  33598. /**
  33599. * Returns the current version of the framework
  33600. */
  33601. static get Version(): string;
  33602. /** Gets the list of created engines */
  33603. static get Instances(): Engine[];
  33604. /**
  33605. * Gets the latest created engine
  33606. */
  33607. static get LastCreatedEngine(): Nullable<Engine>;
  33608. /**
  33609. * Gets the latest created scene
  33610. */
  33611. static get LastCreatedScene(): Nullable<Scene>;
  33612. /**
  33613. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33614. * @param flag defines which part of the materials must be marked as dirty
  33615. * @param predicate defines a predicate used to filter which materials should be affected
  33616. */
  33617. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33618. /**
  33619. * Method called to create the default loading screen.
  33620. * This can be overriden in your own app.
  33621. * @param canvas The rendering canvas element
  33622. * @returns The loading screen
  33623. */
  33624. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33625. /**
  33626. * Method called to create the default rescale post process on each engine.
  33627. */
  33628. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33629. /**
  33630. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33631. **/
  33632. enableOfflineSupport: boolean;
  33633. /**
  33634. * 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)
  33635. **/
  33636. disableManifestCheck: boolean;
  33637. /**
  33638. * Gets the list of created scenes
  33639. */
  33640. scenes: Scene[];
  33641. /**
  33642. * Event raised when a new scene is created
  33643. */
  33644. onNewSceneAddedObservable: Observable<Scene>;
  33645. /**
  33646. * Gets the list of created postprocesses
  33647. */
  33648. postProcesses: PostProcess[];
  33649. /**
  33650. * Gets a boolean indicating if the pointer is currently locked
  33651. */
  33652. isPointerLock: boolean;
  33653. /**
  33654. * Observable event triggered each time the rendering canvas is resized
  33655. */
  33656. onResizeObservable: Observable<Engine>;
  33657. /**
  33658. * Observable event triggered each time the canvas loses focus
  33659. */
  33660. onCanvasBlurObservable: Observable<Engine>;
  33661. /**
  33662. * Observable event triggered each time the canvas gains focus
  33663. */
  33664. onCanvasFocusObservable: Observable<Engine>;
  33665. /**
  33666. * Observable event triggered each time the canvas receives pointerout event
  33667. */
  33668. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33669. /**
  33670. * Observable raised when the engine begins a new frame
  33671. */
  33672. onBeginFrameObservable: Observable<Engine>;
  33673. /**
  33674. * If set, will be used to request the next animation frame for the render loop
  33675. */
  33676. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33677. /**
  33678. * Observable raised when the engine ends the current frame
  33679. */
  33680. onEndFrameObservable: Observable<Engine>;
  33681. /**
  33682. * Observable raised when the engine is about to compile a shader
  33683. */
  33684. onBeforeShaderCompilationObservable: Observable<Engine>;
  33685. /**
  33686. * Observable raised when the engine has jsut compiled a shader
  33687. */
  33688. onAfterShaderCompilationObservable: Observable<Engine>;
  33689. /**
  33690. * Gets the audio engine
  33691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33692. * @ignorenaming
  33693. */
  33694. static audioEngine: IAudioEngine;
  33695. /**
  33696. * Default AudioEngine factory responsible of creating the Audio Engine.
  33697. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33698. */
  33699. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33700. /**
  33701. * Default offline support factory responsible of creating a tool used to store data locally.
  33702. * By default, this will create a Database object if the workload has been embedded.
  33703. */
  33704. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33705. private _loadingScreen;
  33706. private _pointerLockRequested;
  33707. private _dummyFramebuffer;
  33708. private _rescalePostProcess;
  33709. private _deterministicLockstep;
  33710. private _lockstepMaxSteps;
  33711. private _timeStep;
  33712. protected get _supportsHardwareTextureRescaling(): boolean;
  33713. private _fps;
  33714. private _deltaTime;
  33715. /** @hidden */
  33716. _drawCalls: PerfCounter;
  33717. /** 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 */
  33718. canvasTabIndex: number;
  33719. /**
  33720. * Turn this value on if you want to pause FPS computation when in background
  33721. */
  33722. disablePerformanceMonitorInBackground: boolean;
  33723. private _performanceMonitor;
  33724. /**
  33725. * Gets the performance monitor attached to this engine
  33726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33727. */
  33728. get performanceMonitor(): PerformanceMonitor;
  33729. private _onFocus;
  33730. private _onBlur;
  33731. private _onCanvasPointerOut;
  33732. private _onCanvasBlur;
  33733. private _onCanvasFocus;
  33734. private _onFullscreenChange;
  33735. private _onPointerLockChange;
  33736. /**
  33737. * Gets the HTML element used to attach event listeners
  33738. * @returns a HTML element
  33739. */
  33740. getInputElement(): Nullable<HTMLElement>;
  33741. /**
  33742. * Creates a new engine
  33743. * @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
  33744. * @param antialias defines enable antialiasing (default: false)
  33745. * @param options defines further options to be sent to the getContext() function
  33746. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33747. */
  33748. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33749. /**
  33750. * Gets current aspect ratio
  33751. * @param viewportOwner defines the camera to use to get the aspect ratio
  33752. * @param useScreen defines if screen size must be used (or the current render target if any)
  33753. * @returns a number defining the aspect ratio
  33754. */
  33755. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33756. /**
  33757. * Gets current screen aspect ratio
  33758. * @returns a number defining the aspect ratio
  33759. */
  33760. getScreenAspectRatio(): number;
  33761. /**
  33762. * Gets the client rect of the HTML canvas attached with the current webGL context
  33763. * @returns a client rectanglee
  33764. */
  33765. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33766. /**
  33767. * Gets the client rect of the HTML element used for events
  33768. * @returns a client rectanglee
  33769. */
  33770. getInputElementClientRect(): Nullable<ClientRect>;
  33771. /**
  33772. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33774. * @returns true if engine is in deterministic lock step mode
  33775. */
  33776. isDeterministicLockStep(): boolean;
  33777. /**
  33778. * Gets the max steps when engine is running in deterministic lock step
  33779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33780. * @returns the max steps
  33781. */
  33782. getLockstepMaxSteps(): number;
  33783. /**
  33784. * Returns the time in ms between steps when using deterministic lock step.
  33785. * @returns time step in (ms)
  33786. */
  33787. getTimeStep(): number;
  33788. /**
  33789. * Force the mipmap generation for the given render target texture
  33790. * @param texture defines the render target texture to use
  33791. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33792. */
  33793. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33794. /** States */
  33795. /**
  33796. * Set various states to the webGL context
  33797. * @param culling defines backface culling state
  33798. * @param zOffset defines the value to apply to zOffset (0 by default)
  33799. * @param force defines if states must be applied even if cache is up to date
  33800. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33801. */
  33802. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33803. /**
  33804. * Set the z offset to apply to current rendering
  33805. * @param value defines the offset to apply
  33806. */
  33807. setZOffset(value: number): void;
  33808. /**
  33809. * Gets the current value of the zOffset
  33810. * @returns the current zOffset state
  33811. */
  33812. getZOffset(): number;
  33813. /**
  33814. * Enable or disable depth buffering
  33815. * @param enable defines the state to set
  33816. */
  33817. setDepthBuffer(enable: boolean): void;
  33818. /**
  33819. * Gets a boolean indicating if depth writing is enabled
  33820. * @returns the current depth writing state
  33821. */
  33822. getDepthWrite(): boolean;
  33823. /**
  33824. * Enable or disable depth writing
  33825. * @param enable defines the state to set
  33826. */
  33827. setDepthWrite(enable: boolean): void;
  33828. /**
  33829. * Gets a boolean indicating if stencil buffer is enabled
  33830. * @returns the current stencil buffer state
  33831. */
  33832. getStencilBuffer(): boolean;
  33833. /**
  33834. * Enable or disable the stencil buffer
  33835. * @param enable defines if the stencil buffer must be enabled or disabled
  33836. */
  33837. setStencilBuffer(enable: boolean): void;
  33838. /**
  33839. * Gets the current stencil mask
  33840. * @returns a number defining the new stencil mask to use
  33841. */
  33842. getStencilMask(): number;
  33843. /**
  33844. * Sets the current stencil mask
  33845. * @param mask defines the new stencil mask to use
  33846. */
  33847. setStencilMask(mask: number): void;
  33848. /**
  33849. * Gets the current stencil function
  33850. * @returns a number defining the stencil function to use
  33851. */
  33852. getStencilFunction(): number;
  33853. /**
  33854. * Gets the current stencil reference value
  33855. * @returns a number defining the stencil reference value to use
  33856. */
  33857. getStencilFunctionReference(): number;
  33858. /**
  33859. * Gets the current stencil mask
  33860. * @returns a number defining the stencil mask to use
  33861. */
  33862. getStencilFunctionMask(): number;
  33863. /**
  33864. * Sets the current stencil function
  33865. * @param stencilFunc defines the new stencil function to use
  33866. */
  33867. setStencilFunction(stencilFunc: number): void;
  33868. /**
  33869. * Sets the current stencil reference
  33870. * @param reference defines the new stencil reference to use
  33871. */
  33872. setStencilFunctionReference(reference: number): void;
  33873. /**
  33874. * Sets the current stencil mask
  33875. * @param mask defines the new stencil mask to use
  33876. */
  33877. setStencilFunctionMask(mask: number): void;
  33878. /**
  33879. * Gets the current stencil operation when stencil fails
  33880. * @returns a number defining stencil operation to use when stencil fails
  33881. */
  33882. getStencilOperationFail(): number;
  33883. /**
  33884. * Gets the current stencil operation when depth fails
  33885. * @returns a number defining stencil operation to use when depth fails
  33886. */
  33887. getStencilOperationDepthFail(): number;
  33888. /**
  33889. * Gets the current stencil operation when stencil passes
  33890. * @returns a number defining stencil operation to use when stencil passes
  33891. */
  33892. getStencilOperationPass(): number;
  33893. /**
  33894. * Sets the stencil operation to use when stencil fails
  33895. * @param operation defines the stencil operation to use when stencil fails
  33896. */
  33897. setStencilOperationFail(operation: number): void;
  33898. /**
  33899. * Sets the stencil operation to use when depth fails
  33900. * @param operation defines the stencil operation to use when depth fails
  33901. */
  33902. setStencilOperationDepthFail(operation: number): void;
  33903. /**
  33904. * Sets the stencil operation to use when stencil passes
  33905. * @param operation defines the stencil operation to use when stencil passes
  33906. */
  33907. setStencilOperationPass(operation: number): void;
  33908. /**
  33909. * Sets a boolean indicating if the dithering state is enabled or disabled
  33910. * @param value defines the dithering state
  33911. */
  33912. setDitheringState(value: boolean): void;
  33913. /**
  33914. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33915. * @param value defines the rasterizer state
  33916. */
  33917. setRasterizerState(value: boolean): void;
  33918. /**
  33919. * Gets the current depth function
  33920. * @returns a number defining the depth function
  33921. */
  33922. getDepthFunction(): Nullable<number>;
  33923. /**
  33924. * Sets the current depth function
  33925. * @param depthFunc defines the function to use
  33926. */
  33927. setDepthFunction(depthFunc: number): void;
  33928. /**
  33929. * Sets the current depth function to GREATER
  33930. */
  33931. setDepthFunctionToGreater(): void;
  33932. /**
  33933. * Sets the current depth function to GEQUAL
  33934. */
  33935. setDepthFunctionToGreaterOrEqual(): void;
  33936. /**
  33937. * Sets the current depth function to LESS
  33938. */
  33939. setDepthFunctionToLess(): void;
  33940. /**
  33941. * Sets the current depth function to LEQUAL
  33942. */
  33943. setDepthFunctionToLessOrEqual(): void;
  33944. private _cachedStencilBuffer;
  33945. private _cachedStencilFunction;
  33946. private _cachedStencilMask;
  33947. private _cachedStencilOperationPass;
  33948. private _cachedStencilOperationFail;
  33949. private _cachedStencilOperationDepthFail;
  33950. private _cachedStencilReference;
  33951. /**
  33952. * Caches the the state of the stencil buffer
  33953. */
  33954. cacheStencilState(): void;
  33955. /**
  33956. * Restores the state of the stencil buffer
  33957. */
  33958. restoreStencilState(): void;
  33959. /**
  33960. * Directly set the WebGL Viewport
  33961. * @param x defines the x coordinate of the viewport (in screen space)
  33962. * @param y defines the y coordinate of the viewport (in screen space)
  33963. * @param width defines the width of the viewport (in screen space)
  33964. * @param height defines the height of the viewport (in screen space)
  33965. * @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
  33966. */
  33967. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33968. /**
  33969. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33970. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33971. * @param y defines the y-coordinate of the corner of the clear rectangle
  33972. * @param width defines the width of the clear rectangle
  33973. * @param height defines the height of the clear rectangle
  33974. * @param clearColor defines the clear color
  33975. */
  33976. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33977. /**
  33978. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33979. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33980. * @param y defines the y-coordinate of the corner of the clear rectangle
  33981. * @param width defines the width of the clear rectangle
  33982. * @param height defines the height of the clear rectangle
  33983. */
  33984. enableScissor(x: number, y: number, width: number, height: number): void;
  33985. /**
  33986. * Disable previously set scissor test rectangle
  33987. */
  33988. disableScissor(): void;
  33989. protected _reportDrawCall(): void;
  33990. /**
  33991. * Initializes a webVR display and starts listening to display change events
  33992. * The onVRDisplayChangedObservable will be notified upon these changes
  33993. * @returns The onVRDisplayChangedObservable
  33994. */
  33995. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33996. /** @hidden */
  33997. _prepareVRComponent(): void;
  33998. /** @hidden */
  33999. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34000. /** @hidden */
  34001. _submitVRFrame(): void;
  34002. /**
  34003. * Call this function to leave webVR mode
  34004. * Will do nothing if webVR is not supported or if there is no webVR device
  34005. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34006. */
  34007. disableVR(): void;
  34008. /**
  34009. * Gets a boolean indicating that the system is in VR mode and is presenting
  34010. * @returns true if VR mode is engaged
  34011. */
  34012. isVRPresenting(): boolean;
  34013. /** @hidden */
  34014. _requestVRFrame(): void;
  34015. /** @hidden */
  34016. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34017. /**
  34018. * Gets the source code of the vertex shader associated with a specific webGL program
  34019. * @param program defines the program to use
  34020. * @returns a string containing the source code of the vertex shader associated with the program
  34021. */
  34022. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34023. /**
  34024. * Gets the source code of the fragment shader associated with a specific webGL program
  34025. * @param program defines the program to use
  34026. * @returns a string containing the source code of the fragment shader associated with the program
  34027. */
  34028. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34029. /**
  34030. * Sets a depth stencil texture from a render target to the according uniform.
  34031. * @param channel The texture channel
  34032. * @param uniform The uniform to set
  34033. * @param texture The render target texture containing the depth stencil texture to apply
  34034. */
  34035. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34036. /**
  34037. * Sets a texture to the webGL context from a postprocess
  34038. * @param channel defines the channel to use
  34039. * @param postProcess defines the source postprocess
  34040. */
  34041. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34042. /**
  34043. * Binds the output of the passed in post process to the texture channel specified
  34044. * @param channel The channel the texture should be bound to
  34045. * @param postProcess The post process which's output should be bound
  34046. */
  34047. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34048. /** @hidden */
  34049. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34050. protected _rebuildBuffers(): void;
  34051. /** @hidden */
  34052. _renderFrame(): void;
  34053. _renderLoop(): void;
  34054. /** @hidden */
  34055. _renderViews(): boolean;
  34056. /**
  34057. * Toggle full screen mode
  34058. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34059. */
  34060. switchFullscreen(requestPointerLock: boolean): void;
  34061. /**
  34062. * Enters full screen mode
  34063. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34064. */
  34065. enterFullscreen(requestPointerLock: boolean): void;
  34066. /**
  34067. * Exits full screen mode
  34068. */
  34069. exitFullscreen(): void;
  34070. /**
  34071. * Enters Pointerlock mode
  34072. */
  34073. enterPointerlock(): void;
  34074. /**
  34075. * Exits Pointerlock mode
  34076. */
  34077. exitPointerlock(): void;
  34078. /**
  34079. * Begin a new frame
  34080. */
  34081. beginFrame(): void;
  34082. /**
  34083. * Enf the current frame
  34084. */
  34085. endFrame(): void;
  34086. resize(): void;
  34087. /**
  34088. * Force a specific size of the canvas
  34089. * @param width defines the new canvas' width
  34090. * @param height defines the new canvas' height
  34091. */
  34092. setSize(width: number, height: number): void;
  34093. /**
  34094. * Updates a dynamic vertex buffer.
  34095. * @param vertexBuffer the vertex buffer to update
  34096. * @param data the data used to update the vertex buffer
  34097. * @param byteOffset the byte offset of the data
  34098. * @param byteLength the byte length of the data
  34099. */
  34100. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34101. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34102. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34103. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34104. _releaseTexture(texture: InternalTexture): void;
  34105. /**
  34106. * @hidden
  34107. * Rescales a texture
  34108. * @param source input texutre
  34109. * @param destination destination texture
  34110. * @param scene scene to use to render the resize
  34111. * @param internalFormat format to use when resizing
  34112. * @param onComplete callback to be called when resize has completed
  34113. */
  34114. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34115. /**
  34116. * Gets the current framerate
  34117. * @returns a number representing the framerate
  34118. */
  34119. getFps(): number;
  34120. /**
  34121. * Gets the time spent between current and previous frame
  34122. * @returns a number representing the delta time in ms
  34123. */
  34124. getDeltaTime(): number;
  34125. private _measureFps;
  34126. /** @hidden */
  34127. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34128. /**
  34129. * Update a dynamic index buffer
  34130. * @param indexBuffer defines the target index buffer
  34131. * @param indices defines the data to update
  34132. * @param offset defines the offset in the target index buffer where update should start
  34133. */
  34134. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34135. /**
  34136. * Updates the sample count of a render target texture
  34137. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34138. * @param texture defines the texture to update
  34139. * @param samples defines the sample count to set
  34140. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34141. */
  34142. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34143. /**
  34144. * Updates a depth texture Comparison Mode and Function.
  34145. * If the comparison Function is equal to 0, the mode will be set to none.
  34146. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34147. * @param texture The texture to set the comparison function for
  34148. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34149. */
  34150. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34151. /**
  34152. * Creates a webGL buffer to use with instanciation
  34153. * @param capacity defines the size of the buffer
  34154. * @returns the webGL buffer
  34155. */
  34156. createInstancesBuffer(capacity: number): DataBuffer;
  34157. /**
  34158. * Delete a webGL buffer used with instanciation
  34159. * @param buffer defines the webGL buffer to delete
  34160. */
  34161. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34162. private _clientWaitAsync;
  34163. /** @hidden */
  34164. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34165. /** @hidden */
  34166. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34167. dispose(): void;
  34168. private _disableTouchAction;
  34169. /**
  34170. * Display the loading screen
  34171. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34172. */
  34173. displayLoadingUI(): void;
  34174. /**
  34175. * Hide the loading screen
  34176. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34177. */
  34178. hideLoadingUI(): void;
  34179. /**
  34180. * Gets the current loading screen object
  34181. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34182. */
  34183. get loadingScreen(): ILoadingScreen;
  34184. /**
  34185. * Sets the current loading screen object
  34186. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34187. */
  34188. set loadingScreen(loadingScreen: ILoadingScreen);
  34189. /**
  34190. * Sets the current loading screen text
  34191. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34192. */
  34193. set loadingUIText(text: string);
  34194. /**
  34195. * Sets the current loading screen background color
  34196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34197. */
  34198. set loadingUIBackgroundColor(color: string);
  34199. /** Pointerlock and fullscreen */
  34200. /**
  34201. * Ask the browser to promote the current element to pointerlock mode
  34202. * @param element defines the DOM element to promote
  34203. */
  34204. static _RequestPointerlock(element: HTMLElement): void;
  34205. /**
  34206. * Asks the browser to exit pointerlock mode
  34207. */
  34208. static _ExitPointerlock(): void;
  34209. /**
  34210. * Ask the browser to promote the current element to fullscreen rendering mode
  34211. * @param element defines the DOM element to promote
  34212. */
  34213. static _RequestFullscreen(element: HTMLElement): void;
  34214. /**
  34215. * Asks the browser to exit fullscreen mode
  34216. */
  34217. static _ExitFullscreen(): void;
  34218. }
  34219. }
  34220. declare module BABYLON {
  34221. /**
  34222. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34223. * during the life time of the application.
  34224. */
  34225. export class EngineStore {
  34226. /** Gets the list of created engines */
  34227. static Instances: Engine[];
  34228. /** @hidden */
  34229. static _LastCreatedScene: Nullable<Scene>;
  34230. /**
  34231. * Gets the latest created engine
  34232. */
  34233. static get LastCreatedEngine(): Nullable<Engine>;
  34234. /**
  34235. * Gets the latest created scene
  34236. */
  34237. static get LastCreatedScene(): Nullable<Scene>;
  34238. /**
  34239. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34240. * @ignorenaming
  34241. */
  34242. static UseFallbackTexture: boolean;
  34243. /**
  34244. * Texture content used if a texture cannot loaded
  34245. * @ignorenaming
  34246. */
  34247. static FallbackTexture: string;
  34248. }
  34249. }
  34250. declare module BABYLON {
  34251. /**
  34252. * Helper class that provides a small promise polyfill
  34253. */
  34254. export class PromisePolyfill {
  34255. /**
  34256. * Static function used to check if the polyfill is required
  34257. * If this is the case then the function will inject the polyfill to window.Promise
  34258. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34259. */
  34260. static Apply(force?: boolean): void;
  34261. }
  34262. }
  34263. declare module BABYLON {
  34264. /**
  34265. * Interface for screenshot methods with describe argument called `size` as object with options
  34266. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34267. */
  34268. export interface IScreenshotSize {
  34269. /**
  34270. * number in pixels for canvas height
  34271. */
  34272. height?: number;
  34273. /**
  34274. * multiplier allowing render at a higher or lower resolution
  34275. * If value is defined then height and width will be ignored and taken from camera
  34276. */
  34277. precision?: number;
  34278. /**
  34279. * number in pixels for canvas width
  34280. */
  34281. width?: number;
  34282. }
  34283. }
  34284. declare module BABYLON {
  34285. interface IColor4Like {
  34286. r: float;
  34287. g: float;
  34288. b: float;
  34289. a: float;
  34290. }
  34291. /**
  34292. * Class containing a set of static utilities functions
  34293. */
  34294. export class Tools {
  34295. /**
  34296. * Gets or sets the base URL to use to load assets
  34297. */
  34298. static get BaseUrl(): string;
  34299. static set BaseUrl(value: string);
  34300. /**
  34301. * Enable/Disable Custom HTTP Request Headers globally.
  34302. * default = false
  34303. * @see CustomRequestHeaders
  34304. */
  34305. static UseCustomRequestHeaders: boolean;
  34306. /**
  34307. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34308. * i.e. when loading files, where the server/service expects an Authorization header
  34309. */
  34310. static CustomRequestHeaders: {
  34311. [key: string]: string;
  34312. };
  34313. /**
  34314. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34315. */
  34316. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34317. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34318. /**
  34319. * Default behaviour for cors in the application.
  34320. * It can be a string if the expected behavior is identical in the entire app.
  34321. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34322. */
  34323. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34324. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34325. /**
  34326. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34327. * @ignorenaming
  34328. */
  34329. static get UseFallbackTexture(): boolean;
  34330. static set UseFallbackTexture(value: boolean);
  34331. /**
  34332. * Use this object to register external classes like custom textures or material
  34333. * to allow the laoders to instantiate them
  34334. */
  34335. static get RegisteredExternalClasses(): {
  34336. [key: string]: Object;
  34337. };
  34338. static set RegisteredExternalClasses(classes: {
  34339. [key: string]: Object;
  34340. });
  34341. /**
  34342. * Texture content used if a texture cannot loaded
  34343. * @ignorenaming
  34344. */
  34345. static get fallbackTexture(): string;
  34346. static set fallbackTexture(value: string);
  34347. /**
  34348. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34349. * @param u defines the coordinate on X axis
  34350. * @param v defines the coordinate on Y axis
  34351. * @param width defines the width of the source data
  34352. * @param height defines the height of the source data
  34353. * @param pixels defines the source byte array
  34354. * @param color defines the output color
  34355. */
  34356. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34357. /**
  34358. * Interpolates between a and b via alpha
  34359. * @param a The lower value (returned when alpha = 0)
  34360. * @param b The upper value (returned when alpha = 1)
  34361. * @param alpha The interpolation-factor
  34362. * @return The mixed value
  34363. */
  34364. static Mix(a: number, b: number, alpha: number): number;
  34365. /**
  34366. * Tries to instantiate a new object from a given class name
  34367. * @param className defines the class name to instantiate
  34368. * @returns the new object or null if the system was not able to do the instantiation
  34369. */
  34370. static Instantiate(className: string): any;
  34371. /**
  34372. * Provides a slice function that will work even on IE
  34373. * @param data defines the array to slice
  34374. * @param start defines the start of the data (optional)
  34375. * @param end defines the end of the data (optional)
  34376. * @returns the new sliced array
  34377. */
  34378. static Slice<T>(data: T, start?: number, end?: number): T;
  34379. /**
  34380. * Polyfill for setImmediate
  34381. * @param action defines the action to execute after the current execution block
  34382. */
  34383. static SetImmediate(action: () => void): void;
  34384. /**
  34385. * Function indicating if a number is an exponent of 2
  34386. * @param value defines the value to test
  34387. * @returns true if the value is an exponent of 2
  34388. */
  34389. static IsExponentOfTwo(value: number): boolean;
  34390. private static _tmpFloatArray;
  34391. /**
  34392. * Returns the nearest 32-bit single precision float representation of a Number
  34393. * @param value A Number. If the parameter is of a different type, it will get converted
  34394. * to a number or to NaN if it cannot be converted
  34395. * @returns number
  34396. */
  34397. static FloatRound(value: number): number;
  34398. /**
  34399. * Extracts the filename from a path
  34400. * @param path defines the path to use
  34401. * @returns the filename
  34402. */
  34403. static GetFilename(path: string): string;
  34404. /**
  34405. * Extracts the "folder" part of a path (everything before the filename).
  34406. * @param uri The URI to extract the info from
  34407. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34408. * @returns The "folder" part of the path
  34409. */
  34410. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34411. /**
  34412. * Extracts text content from a DOM element hierarchy
  34413. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34414. */
  34415. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34416. /**
  34417. * Convert an angle in radians to degrees
  34418. * @param angle defines the angle to convert
  34419. * @returns the angle in degrees
  34420. */
  34421. static ToDegrees(angle: number): number;
  34422. /**
  34423. * Convert an angle in degrees to radians
  34424. * @param angle defines the angle to convert
  34425. * @returns the angle in radians
  34426. */
  34427. static ToRadians(angle: number): number;
  34428. /**
  34429. * Returns an array if obj is not an array
  34430. * @param obj defines the object to evaluate as an array
  34431. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34432. * @returns either obj directly if obj is an array or a new array containing obj
  34433. */
  34434. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34435. /**
  34436. * Gets the pointer prefix to use
  34437. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34438. */
  34439. static GetPointerPrefix(): string;
  34440. /**
  34441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34442. * @param url define the url we are trying
  34443. * @param element define the dom element where to configure the cors policy
  34444. */
  34445. static SetCorsBehavior(url: string | string[], element: {
  34446. crossOrigin: string | null;
  34447. }): void;
  34448. /**
  34449. * Removes unwanted characters from an url
  34450. * @param url defines the url to clean
  34451. * @returns the cleaned url
  34452. */
  34453. static CleanUrl(url: string): string;
  34454. /**
  34455. * Gets or sets a function used to pre-process url before using them to load assets
  34456. */
  34457. static get PreprocessUrl(): (url: string) => string;
  34458. static set PreprocessUrl(processor: (url: string) => string);
  34459. /**
  34460. * Loads an image as an HTMLImageElement.
  34461. * @param input url string, ArrayBuffer, or Blob to load
  34462. * @param onLoad callback called when the image successfully loads
  34463. * @param onError callback called when the image fails to load
  34464. * @param offlineProvider offline provider for caching
  34465. * @param mimeType optional mime type
  34466. * @returns the HTMLImageElement of the loaded image
  34467. */
  34468. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34469. /**
  34470. * Loads a file from a url
  34471. * @param url url string, ArrayBuffer, or Blob to load
  34472. * @param onSuccess callback called when the file successfully loads
  34473. * @param onProgress callback called while file is loading (if the server supports this mode)
  34474. * @param offlineProvider defines the offline provider for caching
  34475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34476. * @param onError callback called when the file fails to load
  34477. * @returns a file request object
  34478. */
  34479. 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;
  34480. /**
  34481. * Loads a file from a url
  34482. * @param url the file url to load
  34483. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34484. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34485. */
  34486. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34487. /**
  34488. * Load a script (identified by an url). When the url returns, the
  34489. * content of this file is added into a new script element, attached to the DOM (body element)
  34490. * @param scriptUrl defines the url of the script to laod
  34491. * @param onSuccess defines the callback called when the script is loaded
  34492. * @param onError defines the callback to call if an error occurs
  34493. * @param scriptId defines the id of the script element
  34494. */
  34495. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34496. /**
  34497. * Load an asynchronous script (identified by an url). When the url returns, the
  34498. * content of this file is added into a new script element, attached to the DOM (body element)
  34499. * @param scriptUrl defines the url of the script to laod
  34500. * @param scriptId defines the id of the script element
  34501. * @returns a promise request object
  34502. */
  34503. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34504. /**
  34505. * Loads a file from a blob
  34506. * @param fileToLoad defines the blob to use
  34507. * @param callback defines the callback to call when data is loaded
  34508. * @param progressCallback defines the callback to call during loading process
  34509. * @returns a file request object
  34510. */
  34511. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34512. /**
  34513. * Reads a file from a File object
  34514. * @param file defines the file to load
  34515. * @param onSuccess defines the callback to call when data is loaded
  34516. * @param onProgress defines the callback to call during loading process
  34517. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34518. * @param onError defines the callback to call when an error occurs
  34519. * @returns a file request object
  34520. */
  34521. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34522. /**
  34523. * Creates a data url from a given string content
  34524. * @param content defines the content to convert
  34525. * @returns the new data url link
  34526. */
  34527. static FileAsURL(content: string): string;
  34528. /**
  34529. * Format the given number to a specific decimal format
  34530. * @param value defines the number to format
  34531. * @param decimals defines the number of decimals to use
  34532. * @returns the formatted string
  34533. */
  34534. static Format(value: number, decimals?: number): string;
  34535. /**
  34536. * Tries to copy an object by duplicating every property
  34537. * @param source defines the source object
  34538. * @param destination defines the target object
  34539. * @param doNotCopyList defines a list of properties to avoid
  34540. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34541. */
  34542. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34543. /**
  34544. * Gets a boolean indicating if the given object has no own property
  34545. * @param obj defines the object to test
  34546. * @returns true if object has no own property
  34547. */
  34548. static IsEmpty(obj: any): boolean;
  34549. /**
  34550. * Function used to register events at window level
  34551. * @param windowElement defines the Window object to use
  34552. * @param events defines the events to register
  34553. */
  34554. static RegisterTopRootEvents(windowElement: Window, events: {
  34555. name: string;
  34556. handler: Nullable<(e: FocusEvent) => any>;
  34557. }[]): void;
  34558. /**
  34559. * Function used to unregister events from window level
  34560. * @param windowElement defines the Window object to use
  34561. * @param events defines the events to unregister
  34562. */
  34563. static UnregisterTopRootEvents(windowElement: Window, events: {
  34564. name: string;
  34565. handler: Nullable<(e: FocusEvent) => any>;
  34566. }[]): void;
  34567. /**
  34568. * @ignore
  34569. */
  34570. static _ScreenshotCanvas: HTMLCanvasElement;
  34571. /**
  34572. * Dumps the current bound framebuffer
  34573. * @param width defines the rendering width
  34574. * @param height defines the rendering height
  34575. * @param engine defines the hosting engine
  34576. * @param successCallback defines the callback triggered once the data are available
  34577. * @param mimeType defines the mime type of the result
  34578. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34579. */
  34580. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34581. /**
  34582. * Converts the canvas data to blob.
  34583. * This acts as a polyfill for browsers not supporting the to blob function.
  34584. * @param canvas Defines the canvas to extract the data from
  34585. * @param successCallback Defines the callback triggered once the data are available
  34586. * @param mimeType Defines the mime type of the result
  34587. */
  34588. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34589. /**
  34590. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34591. * @param successCallback defines the callback triggered once the data are available
  34592. * @param mimeType defines the mime type of the result
  34593. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34594. */
  34595. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34596. /**
  34597. * Downloads a blob in the browser
  34598. * @param blob defines the blob to download
  34599. * @param fileName defines the name of the downloaded file
  34600. */
  34601. static Download(blob: Blob, fileName: string): void;
  34602. /**
  34603. * Captures a screenshot of the current rendering
  34604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34605. * @param engine defines the rendering engine
  34606. * @param camera defines the source camera
  34607. * @param size This parameter can be set to a single number or to an object with the
  34608. * following (optional) properties: precision, width, height. If a single number is passed,
  34609. * it will be used for both width and height. If an object is passed, the screenshot size
  34610. * will be derived from the parameters. The precision property is a multiplier allowing
  34611. * rendering at a higher or lower resolution
  34612. * @param successCallback defines the callback receives a single parameter which contains the
  34613. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34614. * src parameter of an <img> to display it
  34615. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34616. * Check your browser for supported MIME types
  34617. */
  34618. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34619. /**
  34620. * Captures a screenshot of the current rendering
  34621. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34622. * @param engine defines the rendering engine
  34623. * @param camera defines the source camera
  34624. * @param size This parameter can be set to a single number or to an object with the
  34625. * following (optional) properties: precision, width, height. If a single number is passed,
  34626. * it will be used for both width and height. If an object is passed, the screenshot size
  34627. * will be derived from the parameters. The precision property is a multiplier allowing
  34628. * rendering at a higher or lower resolution
  34629. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34630. * Check your browser for supported MIME types
  34631. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34632. * to the src parameter of an <img> to display it
  34633. */
  34634. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34635. /**
  34636. * Generates an image screenshot from the specified camera.
  34637. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34638. * @param engine The engine to use for rendering
  34639. * @param camera The camera to use for rendering
  34640. * @param size This parameter can be set to a single number or to an object with the
  34641. * following (optional) properties: precision, width, height. If a single number is passed,
  34642. * it will be used for both width and height. If an object is passed, the screenshot size
  34643. * will be derived from the parameters. The precision property is a multiplier allowing
  34644. * rendering at a higher or lower resolution
  34645. * @param successCallback The callback receives a single parameter which contains the
  34646. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34647. * src parameter of an <img> to display it
  34648. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34649. * Check your browser for supported MIME types
  34650. * @param samples Texture samples (default: 1)
  34651. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34652. * @param fileName A name for for the downloaded file.
  34653. */
  34654. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34655. /**
  34656. * Generates an image screenshot from the specified camera.
  34657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34658. * @param engine The engine to use for rendering
  34659. * @param camera The camera to use for rendering
  34660. * @param size This parameter can be set to a single number or to an object with the
  34661. * following (optional) properties: precision, width, height. If a single number is passed,
  34662. * it will be used for both width and height. If an object is passed, the screenshot size
  34663. * will be derived from the parameters. The precision property is a multiplier allowing
  34664. * rendering at a higher or lower resolution
  34665. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34666. * Check your browser for supported MIME types
  34667. * @param samples Texture samples (default: 1)
  34668. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34669. * @param fileName A name for for the downloaded file.
  34670. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34671. * to the src parameter of an <img> to display it
  34672. */
  34673. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34674. /**
  34675. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34676. * Be aware Math.random() could cause collisions, but:
  34677. * "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"
  34678. * @returns a pseudo random id
  34679. */
  34680. static RandomId(): string;
  34681. /**
  34682. * Test if the given uri is a base64 string
  34683. * @param uri The uri to test
  34684. * @return True if the uri is a base64 string or false otherwise
  34685. */
  34686. static IsBase64(uri: string): boolean;
  34687. /**
  34688. * Decode the given base64 uri.
  34689. * @param uri The uri to decode
  34690. * @return The decoded base64 data.
  34691. */
  34692. static DecodeBase64(uri: string): ArrayBuffer;
  34693. /**
  34694. * Gets the absolute url.
  34695. * @param url the input url
  34696. * @return the absolute url
  34697. */
  34698. static GetAbsoluteUrl(url: string): string;
  34699. /**
  34700. * No log
  34701. */
  34702. static readonly NoneLogLevel: number;
  34703. /**
  34704. * Only message logs
  34705. */
  34706. static readonly MessageLogLevel: number;
  34707. /**
  34708. * Only warning logs
  34709. */
  34710. static readonly WarningLogLevel: number;
  34711. /**
  34712. * Only error logs
  34713. */
  34714. static readonly ErrorLogLevel: number;
  34715. /**
  34716. * All logs
  34717. */
  34718. static readonly AllLogLevel: number;
  34719. /**
  34720. * Gets a value indicating the number of loading errors
  34721. * @ignorenaming
  34722. */
  34723. static get errorsCount(): number;
  34724. /**
  34725. * Callback called when a new log is added
  34726. */
  34727. static OnNewCacheEntry: (entry: string) => void;
  34728. /**
  34729. * Log a message to the console
  34730. * @param message defines the message to log
  34731. */
  34732. static Log(message: string): void;
  34733. /**
  34734. * Write a warning message to the console
  34735. * @param message defines the message to log
  34736. */
  34737. static Warn(message: string): void;
  34738. /**
  34739. * Write an error message to the console
  34740. * @param message defines the message to log
  34741. */
  34742. static Error(message: string): void;
  34743. /**
  34744. * Gets current log cache (list of logs)
  34745. */
  34746. static get LogCache(): string;
  34747. /**
  34748. * Clears the log cache
  34749. */
  34750. static ClearLogCache(): void;
  34751. /**
  34752. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34753. */
  34754. static set LogLevels(level: number);
  34755. /**
  34756. * Checks if the window object exists
  34757. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34758. */
  34759. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34760. /**
  34761. * No performance log
  34762. */
  34763. static readonly PerformanceNoneLogLevel: number;
  34764. /**
  34765. * Use user marks to log performance
  34766. */
  34767. static readonly PerformanceUserMarkLogLevel: number;
  34768. /**
  34769. * Log performance to the console
  34770. */
  34771. static readonly PerformanceConsoleLogLevel: number;
  34772. private static _performance;
  34773. /**
  34774. * Sets the current performance log level
  34775. */
  34776. static set PerformanceLogLevel(level: number);
  34777. private static _StartPerformanceCounterDisabled;
  34778. private static _EndPerformanceCounterDisabled;
  34779. private static _StartUserMark;
  34780. private static _EndUserMark;
  34781. private static _StartPerformanceConsole;
  34782. private static _EndPerformanceConsole;
  34783. /**
  34784. * Starts a performance counter
  34785. */
  34786. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34787. /**
  34788. * Ends a specific performance coutner
  34789. */
  34790. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34791. /**
  34792. * Gets either window.performance.now() if supported or Date.now() else
  34793. */
  34794. static get Now(): number;
  34795. /**
  34796. * This method will return the name of the class used to create the instance of the given object.
  34797. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34798. * @param object the object to get the class name from
  34799. * @param isType defines if the object is actually a type
  34800. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34801. */
  34802. static GetClassName(object: any, isType?: boolean): string;
  34803. /**
  34804. * Gets the first element of an array satisfying a given predicate
  34805. * @param array defines the array to browse
  34806. * @param predicate defines the predicate to use
  34807. * @returns null if not found or the element
  34808. */
  34809. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34810. /**
  34811. * This method will return the name of the full name of the class, including its owning module (if any).
  34812. * 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).
  34813. * @param object the object to get the class name from
  34814. * @param isType defines if the object is actually a type
  34815. * @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.
  34816. * @ignorenaming
  34817. */
  34818. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34819. /**
  34820. * Returns a promise that resolves after the given amount of time.
  34821. * @param delay Number of milliseconds to delay
  34822. * @returns Promise that resolves after the given amount of time
  34823. */
  34824. static DelayAsync(delay: number): Promise<void>;
  34825. /**
  34826. * Utility function to detect if the current user agent is Safari
  34827. * @returns whether or not the current user agent is safari
  34828. */
  34829. static IsSafari(): boolean;
  34830. }
  34831. /**
  34832. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34833. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34834. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34835. * @param name The name of the class, case should be preserved
  34836. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34837. */
  34838. export function className(name: string, module?: string): (target: Object) => void;
  34839. /**
  34840. * An implementation of a loop for asynchronous functions.
  34841. */
  34842. export class AsyncLoop {
  34843. /**
  34844. * Defines the number of iterations for the loop
  34845. */
  34846. iterations: number;
  34847. /**
  34848. * Defines the current index of the loop.
  34849. */
  34850. index: number;
  34851. private _done;
  34852. private _fn;
  34853. private _successCallback;
  34854. /**
  34855. * Constructor.
  34856. * @param iterations the number of iterations.
  34857. * @param func the function to run each iteration
  34858. * @param successCallback the callback that will be called upon succesful execution
  34859. * @param offset starting offset.
  34860. */
  34861. constructor(
  34862. /**
  34863. * Defines the number of iterations for the loop
  34864. */
  34865. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34866. /**
  34867. * Execute the next iteration. Must be called after the last iteration was finished.
  34868. */
  34869. executeNext(): void;
  34870. /**
  34871. * Break the loop and run the success callback.
  34872. */
  34873. breakLoop(): void;
  34874. /**
  34875. * Create and run an async loop.
  34876. * @param iterations the number of iterations.
  34877. * @param fn the function to run each iteration
  34878. * @param successCallback the callback that will be called upon succesful execution
  34879. * @param offset starting offset.
  34880. * @returns the created async loop object
  34881. */
  34882. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34883. /**
  34884. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34885. * @param iterations total number of iterations
  34886. * @param syncedIterations number of synchronous iterations in each async iteration.
  34887. * @param fn the function to call each iteration.
  34888. * @param callback a success call back that will be called when iterating stops.
  34889. * @param breakFunction a break condition (optional)
  34890. * @param timeout timeout settings for the setTimeout function. default - 0.
  34891. * @returns the created async loop object
  34892. */
  34893. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34894. }
  34895. }
  34896. declare module BABYLON {
  34897. /**
  34898. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34899. * The underlying implementation relies on an associative array to ensure the best performances.
  34900. * The value can be anything including 'null' but except 'undefined'
  34901. */
  34902. export class StringDictionary<T> {
  34903. /**
  34904. * This will clear this dictionary and copy the content from the 'source' one.
  34905. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34906. * @param source the dictionary to take the content from and copy to this dictionary
  34907. */
  34908. copyFrom(source: StringDictionary<T>): void;
  34909. /**
  34910. * Get a value based from its key
  34911. * @param key the given key to get the matching value from
  34912. * @return the value if found, otherwise undefined is returned
  34913. */
  34914. get(key: string): T | undefined;
  34915. /**
  34916. * Get a value from its key or add it if it doesn't exist.
  34917. * This method will ensure you that a given key/data will be present in the dictionary.
  34918. * @param key the given key to get the matching value from
  34919. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34920. * The factory will only be invoked if there's no data for the given key.
  34921. * @return the value corresponding to the key.
  34922. */
  34923. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34924. /**
  34925. * Get a value from its key if present in the dictionary otherwise add it
  34926. * @param key the key to get the value from
  34927. * @param val if there's no such key/value pair in the dictionary add it with this value
  34928. * @return the value corresponding to the key
  34929. */
  34930. getOrAdd(key: string, val: T): T;
  34931. /**
  34932. * Check if there's a given key in the dictionary
  34933. * @param key the key to check for
  34934. * @return true if the key is present, false otherwise
  34935. */
  34936. contains(key: string): boolean;
  34937. /**
  34938. * Add a new key and its corresponding value
  34939. * @param key the key to add
  34940. * @param value the value corresponding to the key
  34941. * @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
  34942. */
  34943. add(key: string, value: T): boolean;
  34944. /**
  34945. * Update a specific value associated to a key
  34946. * @param key defines the key to use
  34947. * @param value defines the value to store
  34948. * @returns true if the value was updated (or false if the key was not found)
  34949. */
  34950. set(key: string, value: T): boolean;
  34951. /**
  34952. * Get the element of the given key and remove it from the dictionary
  34953. * @param key defines the key to search
  34954. * @returns the value associated with the key or null if not found
  34955. */
  34956. getAndRemove(key: string): Nullable<T>;
  34957. /**
  34958. * Remove a key/value from the dictionary.
  34959. * @param key the key to remove
  34960. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34961. */
  34962. remove(key: string): boolean;
  34963. /**
  34964. * Clear the whole content of the dictionary
  34965. */
  34966. clear(): void;
  34967. /**
  34968. * Gets the current count
  34969. */
  34970. get count(): number;
  34971. /**
  34972. * Execute a callback on each key/val of the dictionary.
  34973. * Note that you can remove any element in this dictionary in the callback implementation
  34974. * @param callback the callback to execute on a given key/value pair
  34975. */
  34976. forEach(callback: (key: string, val: T) => void): void;
  34977. /**
  34978. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34979. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34980. * Note that you can remove any element in this dictionary in the callback implementation
  34981. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34982. * @returns the first item
  34983. */
  34984. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34985. private _count;
  34986. private _data;
  34987. }
  34988. }
  34989. declare module BABYLON {
  34990. /** @hidden */
  34991. export interface ICollisionCoordinator {
  34992. createCollider(): Collider;
  34993. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34994. init(scene: Scene): void;
  34995. }
  34996. /** @hidden */
  34997. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34998. private _scene;
  34999. private _scaledPosition;
  35000. private _scaledVelocity;
  35001. private _finalPosition;
  35002. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35003. createCollider(): Collider;
  35004. init(scene: Scene): void;
  35005. private _collideWithWorld;
  35006. }
  35007. }
  35008. declare module BABYLON {
  35009. /**
  35010. * Class used to manage all inputs for the scene.
  35011. */
  35012. export class InputManager {
  35013. /** The distance in pixel that you have to move to prevent some events */
  35014. static DragMovementThreshold: number;
  35015. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35016. static LongPressDelay: number;
  35017. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35018. static DoubleClickDelay: number;
  35019. /** If you need to check double click without raising a single click at first click, enable this flag */
  35020. static ExclusiveDoubleClickMode: boolean;
  35021. private _wheelEventName;
  35022. private _onPointerMove;
  35023. private _onPointerDown;
  35024. private _onPointerUp;
  35025. private _initClickEvent;
  35026. private _initActionManager;
  35027. private _delayedSimpleClick;
  35028. private _delayedSimpleClickTimeout;
  35029. private _previousDelayedSimpleClickTimeout;
  35030. private _meshPickProceed;
  35031. private _previousButtonPressed;
  35032. private _currentPickResult;
  35033. private _previousPickResult;
  35034. private _totalPointersPressed;
  35035. private _doubleClickOccured;
  35036. private _pointerOverMesh;
  35037. private _pickedDownMesh;
  35038. private _pickedUpMesh;
  35039. private _pointerX;
  35040. private _pointerY;
  35041. private _unTranslatedPointerX;
  35042. private _unTranslatedPointerY;
  35043. private _startingPointerPosition;
  35044. private _previousStartingPointerPosition;
  35045. private _startingPointerTime;
  35046. private _previousStartingPointerTime;
  35047. private _pointerCaptures;
  35048. private _onKeyDown;
  35049. private _onKeyUp;
  35050. private _onCanvasFocusObserver;
  35051. private _onCanvasBlurObserver;
  35052. private _scene;
  35053. /**
  35054. * Creates a new InputManager
  35055. * @param scene defines the hosting scene
  35056. */
  35057. constructor(scene: Scene);
  35058. /**
  35059. * Gets the mesh that is currently under the pointer
  35060. */
  35061. get meshUnderPointer(): Nullable<AbstractMesh>;
  35062. /**
  35063. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35064. */
  35065. get unTranslatedPointer(): Vector2;
  35066. /**
  35067. * Gets or sets the current on-screen X position of the pointer
  35068. */
  35069. get pointerX(): number;
  35070. set pointerX(value: number);
  35071. /**
  35072. * Gets or sets the current on-screen Y position of the pointer
  35073. */
  35074. get pointerY(): number;
  35075. set pointerY(value: number);
  35076. private _updatePointerPosition;
  35077. private _processPointerMove;
  35078. private _setRayOnPointerInfo;
  35079. private _checkPrePointerObservable;
  35080. /**
  35081. * Use this method to simulate a pointer move on a mesh
  35082. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35083. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35084. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35085. */
  35086. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35087. /**
  35088. * Use this method to simulate a pointer down on a mesh
  35089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35092. */
  35093. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35094. private _processPointerDown;
  35095. /** @hidden */
  35096. _isPointerSwiping(): boolean;
  35097. /**
  35098. * Use this method to simulate a pointer up on a mesh
  35099. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35100. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35101. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35102. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35103. */
  35104. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35105. private _processPointerUp;
  35106. /**
  35107. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35108. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35109. * @returns true if the pointer was captured
  35110. */
  35111. isPointerCaptured(pointerId?: number): boolean;
  35112. /**
  35113. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35114. * @param attachUp defines if you want to attach events to pointerup
  35115. * @param attachDown defines if you want to attach events to pointerdown
  35116. * @param attachMove defines if you want to attach events to pointermove
  35117. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35118. */
  35119. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35120. /**
  35121. * Detaches all event handlers
  35122. */
  35123. detachControl(): void;
  35124. /**
  35125. * Force the value of meshUnderPointer
  35126. * @param mesh defines the mesh to use
  35127. */
  35128. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35129. /**
  35130. * Gets the mesh under the pointer
  35131. * @returns a Mesh or null if no mesh is under the pointer
  35132. */
  35133. getPointerOverMesh(): Nullable<AbstractMesh>;
  35134. }
  35135. }
  35136. declare module BABYLON {
  35137. /**
  35138. * Helper class used to generate session unique ID
  35139. */
  35140. export class UniqueIdGenerator {
  35141. private static _UniqueIdCounter;
  35142. /**
  35143. * Gets an unique (relatively to the current scene) Id
  35144. */
  35145. static get UniqueId(): number;
  35146. }
  35147. }
  35148. declare module BABYLON {
  35149. /**
  35150. * This class defines the direct association between an animation and a target
  35151. */
  35152. export class TargetedAnimation {
  35153. /**
  35154. * Animation to perform
  35155. */
  35156. animation: Animation;
  35157. /**
  35158. * Target to animate
  35159. */
  35160. target: any;
  35161. /**
  35162. * Serialize the object
  35163. * @returns the JSON object representing the current entity
  35164. */
  35165. serialize(): any;
  35166. }
  35167. /**
  35168. * Use this class to create coordinated animations on multiple targets
  35169. */
  35170. export class AnimationGroup implements IDisposable {
  35171. /** The name of the animation group */
  35172. name: string;
  35173. private _scene;
  35174. private _targetedAnimations;
  35175. private _animatables;
  35176. private _from;
  35177. private _to;
  35178. private _isStarted;
  35179. private _isPaused;
  35180. private _speedRatio;
  35181. private _loopAnimation;
  35182. private _isAdditive;
  35183. /**
  35184. * Gets or sets the unique id of the node
  35185. */
  35186. uniqueId: number;
  35187. /**
  35188. * This observable will notify when one animation have ended
  35189. */
  35190. onAnimationEndObservable: Observable<TargetedAnimation>;
  35191. /**
  35192. * Observer raised when one animation loops
  35193. */
  35194. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35195. /**
  35196. * Observer raised when all animations have looped
  35197. */
  35198. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35199. /**
  35200. * This observable will notify when all animations have ended.
  35201. */
  35202. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35203. /**
  35204. * This observable will notify when all animations have paused.
  35205. */
  35206. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35207. /**
  35208. * This observable will notify when all animations are playing.
  35209. */
  35210. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35211. /**
  35212. * Gets the first frame
  35213. */
  35214. get from(): number;
  35215. /**
  35216. * Gets the last frame
  35217. */
  35218. get to(): number;
  35219. /**
  35220. * Define if the animations are started
  35221. */
  35222. get isStarted(): boolean;
  35223. /**
  35224. * Gets a value indicating that the current group is playing
  35225. */
  35226. get isPlaying(): boolean;
  35227. /**
  35228. * Gets or sets the speed ratio to use for all animations
  35229. */
  35230. get speedRatio(): number;
  35231. /**
  35232. * Gets or sets the speed ratio to use for all animations
  35233. */
  35234. set speedRatio(value: number);
  35235. /**
  35236. * Gets or sets if all animations should loop or not
  35237. */
  35238. get loopAnimation(): boolean;
  35239. set loopAnimation(value: boolean);
  35240. /**
  35241. * Gets or sets if all animations should be evaluated additively
  35242. */
  35243. get isAdditive(): boolean;
  35244. set isAdditive(value: boolean);
  35245. /**
  35246. * Gets the targeted animations for this animation group
  35247. */
  35248. get targetedAnimations(): Array<TargetedAnimation>;
  35249. /**
  35250. * returning the list of animatables controlled by this animation group.
  35251. */
  35252. get animatables(): Array<Animatable>;
  35253. /**
  35254. * Instantiates a new Animation Group.
  35255. * This helps managing several animations at once.
  35256. * @see http://doc.babylonjs.com/how_to/group
  35257. * @param name Defines the name of the group
  35258. * @param scene Defines the scene the group belongs to
  35259. */
  35260. constructor(
  35261. /** The name of the animation group */
  35262. name: string, scene?: Nullable<Scene>);
  35263. /**
  35264. * Add an animation (with its target) in the group
  35265. * @param animation defines the animation we want to add
  35266. * @param target defines the target of the animation
  35267. * @returns the TargetedAnimation object
  35268. */
  35269. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35270. /**
  35271. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35272. * It can add constant keys at begin or end
  35273. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35274. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35275. * @returns the animation group
  35276. */
  35277. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35278. private _animationLoopCount;
  35279. private _animationLoopFlags;
  35280. private _processLoop;
  35281. /**
  35282. * Start all animations on given targets
  35283. * @param loop defines if animations must loop
  35284. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35285. * @param from defines the from key (optional)
  35286. * @param to defines the to key (optional)
  35287. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35288. * @returns the current animation group
  35289. */
  35290. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35291. /**
  35292. * Pause all animations
  35293. * @returns the animation group
  35294. */
  35295. pause(): AnimationGroup;
  35296. /**
  35297. * Play all animations to initial state
  35298. * This function will start() the animations if they were not started or will restart() them if they were paused
  35299. * @param loop defines if animations must loop
  35300. * @returns the animation group
  35301. */
  35302. play(loop?: boolean): AnimationGroup;
  35303. /**
  35304. * Reset all animations to initial state
  35305. * @returns the animation group
  35306. */
  35307. reset(): AnimationGroup;
  35308. /**
  35309. * Restart animations from key 0
  35310. * @returns the animation group
  35311. */
  35312. restart(): AnimationGroup;
  35313. /**
  35314. * Stop all animations
  35315. * @returns the animation group
  35316. */
  35317. stop(): AnimationGroup;
  35318. /**
  35319. * Set animation weight for all animatables
  35320. * @param weight defines the weight to use
  35321. * @return the animationGroup
  35322. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35323. */
  35324. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35325. /**
  35326. * Synchronize and normalize all animatables with a source animatable
  35327. * @param root defines the root animatable to synchronize with
  35328. * @return the animationGroup
  35329. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35330. */
  35331. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35332. /**
  35333. * Goes to a specific frame in this animation group
  35334. * @param frame the frame number to go to
  35335. * @return the animationGroup
  35336. */
  35337. goToFrame(frame: number): AnimationGroup;
  35338. /**
  35339. * Dispose all associated resources
  35340. */
  35341. dispose(): void;
  35342. private _checkAnimationGroupEnded;
  35343. /**
  35344. * Clone the current animation group and returns a copy
  35345. * @param newName defines the name of the new group
  35346. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35347. * @returns the new aniamtion group
  35348. */
  35349. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35350. /**
  35351. * Serializes the animationGroup to an object
  35352. * @returns Serialized object
  35353. */
  35354. serialize(): any;
  35355. /**
  35356. * Returns a new AnimationGroup object parsed from the source provided.
  35357. * @param parsedAnimationGroup defines the source
  35358. * @param scene defines the scene that will receive the animationGroup
  35359. * @returns a new AnimationGroup
  35360. */
  35361. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35362. /**
  35363. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35364. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35365. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35366. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35367. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35368. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35369. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35370. */
  35371. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35372. /**
  35373. * Returns the string "AnimationGroup"
  35374. * @returns "AnimationGroup"
  35375. */
  35376. getClassName(): string;
  35377. /**
  35378. * Creates a detailled string about the object
  35379. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35380. * @returns a string representing the object
  35381. */
  35382. toString(fullDetails?: boolean): string;
  35383. }
  35384. }
  35385. declare module BABYLON {
  35386. /**
  35387. * Define an interface for all classes that will hold resources
  35388. */
  35389. export interface IDisposable {
  35390. /**
  35391. * Releases all held resources
  35392. */
  35393. dispose(): void;
  35394. }
  35395. /** Interface defining initialization parameters for Scene class */
  35396. export interface SceneOptions {
  35397. /**
  35398. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35399. * It will improve performance when the number of geometries becomes important.
  35400. */
  35401. useGeometryUniqueIdsMap?: boolean;
  35402. /**
  35403. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35404. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35405. */
  35406. useMaterialMeshMap?: boolean;
  35407. /**
  35408. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35409. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35410. */
  35411. useClonedMeshMap?: boolean;
  35412. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35413. virtual?: boolean;
  35414. }
  35415. /**
  35416. * Represents a scene to be rendered by the engine.
  35417. * @see http://doc.babylonjs.com/features/scene
  35418. */
  35419. export class Scene extends AbstractScene implements IAnimatable {
  35420. /** The fog is deactivated */
  35421. static readonly FOGMODE_NONE: number;
  35422. /** The fog density is following an exponential function */
  35423. static readonly FOGMODE_EXP: number;
  35424. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35425. static readonly FOGMODE_EXP2: number;
  35426. /** The fog density is following a linear function. */
  35427. static readonly FOGMODE_LINEAR: number;
  35428. /**
  35429. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35431. */
  35432. static MinDeltaTime: number;
  35433. /**
  35434. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35435. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35436. */
  35437. static MaxDeltaTime: number;
  35438. /**
  35439. * Factory used to create the default material.
  35440. * @param name The name of the material to create
  35441. * @param scene The scene to create the material for
  35442. * @returns The default material
  35443. */
  35444. static DefaultMaterialFactory(scene: Scene): Material;
  35445. /**
  35446. * Factory used to create the a collision coordinator.
  35447. * @returns The collision coordinator
  35448. */
  35449. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35450. /** @hidden */
  35451. _inputManager: InputManager;
  35452. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35453. cameraToUseForPointers: Nullable<Camera>;
  35454. /** @hidden */
  35455. readonly _isScene: boolean;
  35456. /** @hidden */
  35457. _blockEntityCollection: boolean;
  35458. /**
  35459. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35460. */
  35461. autoClear: boolean;
  35462. /**
  35463. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35464. */
  35465. autoClearDepthAndStencil: boolean;
  35466. /**
  35467. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35468. */
  35469. clearColor: Color4;
  35470. /**
  35471. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35472. */
  35473. ambientColor: Color3;
  35474. /**
  35475. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35476. * It should only be one of the following (if not the default embedded one):
  35477. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35478. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35479. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35480. * The material properties need to be setup according to the type of texture in use.
  35481. */
  35482. environmentBRDFTexture: BaseTexture;
  35483. /** @hidden */
  35484. protected _environmentTexture: Nullable<BaseTexture>;
  35485. /**
  35486. * Texture used in all pbr material as the reflection texture.
  35487. * As in the majority of the scene they are the same (exception for multi room and so on),
  35488. * this is easier to reference from here than from all the materials.
  35489. */
  35490. get environmentTexture(): Nullable<BaseTexture>;
  35491. /**
  35492. * Texture used in all pbr material as the reflection texture.
  35493. * As in the majority of the scene they are the same (exception for multi room and so on),
  35494. * this is easier to set here than in all the materials.
  35495. */
  35496. set environmentTexture(value: Nullable<BaseTexture>);
  35497. /** @hidden */
  35498. protected _environmentIntensity: number;
  35499. /**
  35500. * Intensity of the environment in all pbr material.
  35501. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35502. * As in the majority of the scene they are the same (exception for multi room and so on),
  35503. * this is easier to reference from here than from all the materials.
  35504. */
  35505. get environmentIntensity(): number;
  35506. /**
  35507. * Intensity of the environment in all pbr material.
  35508. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35509. * As in the majority of the scene they are the same (exception for multi room and so on),
  35510. * this is easier to set here than in all the materials.
  35511. */
  35512. set environmentIntensity(value: number);
  35513. /** @hidden */
  35514. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35515. /**
  35516. * Default image processing configuration used either in the rendering
  35517. * Forward main pass or through the imageProcessingPostProcess if present.
  35518. * As in the majority of the scene they are the same (exception for multi camera),
  35519. * this is easier to reference from here than from all the materials and post process.
  35520. *
  35521. * No setter as we it is a shared configuration, you can set the values instead.
  35522. */
  35523. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35524. private _forceWireframe;
  35525. /**
  35526. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35527. */
  35528. set forceWireframe(value: boolean);
  35529. get forceWireframe(): boolean;
  35530. private _skipFrustumClipping;
  35531. /**
  35532. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35533. */
  35534. set skipFrustumClipping(value: boolean);
  35535. get skipFrustumClipping(): boolean;
  35536. private _forcePointsCloud;
  35537. /**
  35538. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35539. */
  35540. set forcePointsCloud(value: boolean);
  35541. get forcePointsCloud(): boolean;
  35542. /**
  35543. * Gets or sets the active clipplane 1
  35544. */
  35545. clipPlane: Nullable<Plane>;
  35546. /**
  35547. * Gets or sets the active clipplane 2
  35548. */
  35549. clipPlane2: Nullable<Plane>;
  35550. /**
  35551. * Gets or sets the active clipplane 3
  35552. */
  35553. clipPlane3: Nullable<Plane>;
  35554. /**
  35555. * Gets or sets the active clipplane 4
  35556. */
  35557. clipPlane4: Nullable<Plane>;
  35558. /**
  35559. * Gets or sets the active clipplane 5
  35560. */
  35561. clipPlane5: Nullable<Plane>;
  35562. /**
  35563. * Gets or sets the active clipplane 6
  35564. */
  35565. clipPlane6: Nullable<Plane>;
  35566. /**
  35567. * Gets or sets a boolean indicating if animations are enabled
  35568. */
  35569. animationsEnabled: boolean;
  35570. private _animationPropertiesOverride;
  35571. /**
  35572. * Gets or sets the animation properties override
  35573. */
  35574. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35575. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35576. /**
  35577. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35578. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35579. */
  35580. useConstantAnimationDeltaTime: boolean;
  35581. /**
  35582. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35583. * Please note that it requires to run a ray cast through the scene on every frame
  35584. */
  35585. constantlyUpdateMeshUnderPointer: boolean;
  35586. /**
  35587. * Defines the HTML cursor to use when hovering over interactive elements
  35588. */
  35589. hoverCursor: string;
  35590. /**
  35591. * Defines the HTML default cursor to use (empty by default)
  35592. */
  35593. defaultCursor: string;
  35594. /**
  35595. * Defines whether cursors are handled by the scene.
  35596. */
  35597. doNotHandleCursors: boolean;
  35598. /**
  35599. * This is used to call preventDefault() on pointer down
  35600. * in order to block unwanted artifacts like system double clicks
  35601. */
  35602. preventDefaultOnPointerDown: boolean;
  35603. /**
  35604. * This is used to call preventDefault() on pointer up
  35605. * in order to block unwanted artifacts like system double clicks
  35606. */
  35607. preventDefaultOnPointerUp: boolean;
  35608. /**
  35609. * Gets or sets user defined metadata
  35610. */
  35611. metadata: any;
  35612. /**
  35613. * For internal use only. Please do not use.
  35614. */
  35615. reservedDataStore: any;
  35616. /**
  35617. * Gets the name of the plugin used to load this scene (null by default)
  35618. */
  35619. loadingPluginName: string;
  35620. /**
  35621. * Use this array to add regular expressions used to disable offline support for specific urls
  35622. */
  35623. disableOfflineSupportExceptionRules: RegExp[];
  35624. /**
  35625. * An event triggered when the scene is disposed.
  35626. */
  35627. onDisposeObservable: Observable<Scene>;
  35628. private _onDisposeObserver;
  35629. /** Sets a function to be executed when this scene is disposed. */
  35630. set onDispose(callback: () => void);
  35631. /**
  35632. * An event triggered before rendering the scene (right after animations and physics)
  35633. */
  35634. onBeforeRenderObservable: Observable<Scene>;
  35635. private _onBeforeRenderObserver;
  35636. /** Sets a function to be executed before rendering this scene */
  35637. set beforeRender(callback: Nullable<() => void>);
  35638. /**
  35639. * An event triggered after rendering the scene
  35640. */
  35641. onAfterRenderObservable: Observable<Scene>;
  35642. /**
  35643. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35644. */
  35645. onAfterRenderCameraObservable: Observable<Camera>;
  35646. private _onAfterRenderObserver;
  35647. /** Sets a function to be executed after rendering this scene */
  35648. set afterRender(callback: Nullable<() => void>);
  35649. /**
  35650. * An event triggered before animating the scene
  35651. */
  35652. onBeforeAnimationsObservable: Observable<Scene>;
  35653. /**
  35654. * An event triggered after animations processing
  35655. */
  35656. onAfterAnimationsObservable: Observable<Scene>;
  35657. /**
  35658. * An event triggered before draw calls are ready to be sent
  35659. */
  35660. onBeforeDrawPhaseObservable: Observable<Scene>;
  35661. /**
  35662. * An event triggered after draw calls have been sent
  35663. */
  35664. onAfterDrawPhaseObservable: Observable<Scene>;
  35665. /**
  35666. * An event triggered when the scene is ready
  35667. */
  35668. onReadyObservable: Observable<Scene>;
  35669. /**
  35670. * An event triggered before rendering a camera
  35671. */
  35672. onBeforeCameraRenderObservable: Observable<Camera>;
  35673. private _onBeforeCameraRenderObserver;
  35674. /** Sets a function to be executed before rendering a camera*/
  35675. set beforeCameraRender(callback: () => void);
  35676. /**
  35677. * An event triggered after rendering a camera
  35678. */
  35679. onAfterCameraRenderObservable: Observable<Camera>;
  35680. private _onAfterCameraRenderObserver;
  35681. /** Sets a function to be executed after rendering a camera*/
  35682. set afterCameraRender(callback: () => void);
  35683. /**
  35684. * An event triggered when active meshes evaluation is about to start
  35685. */
  35686. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35687. /**
  35688. * An event triggered when active meshes evaluation is done
  35689. */
  35690. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35691. /**
  35692. * An event triggered when particles rendering is about to start
  35693. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35694. */
  35695. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35696. /**
  35697. * An event triggered when particles rendering is done
  35698. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35699. */
  35700. onAfterParticlesRenderingObservable: Observable<Scene>;
  35701. /**
  35702. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35703. */
  35704. onDataLoadedObservable: Observable<Scene>;
  35705. /**
  35706. * An event triggered when a camera is created
  35707. */
  35708. onNewCameraAddedObservable: Observable<Camera>;
  35709. /**
  35710. * An event triggered when a camera is removed
  35711. */
  35712. onCameraRemovedObservable: Observable<Camera>;
  35713. /**
  35714. * An event triggered when a light is created
  35715. */
  35716. onNewLightAddedObservable: Observable<Light>;
  35717. /**
  35718. * An event triggered when a light is removed
  35719. */
  35720. onLightRemovedObservable: Observable<Light>;
  35721. /**
  35722. * An event triggered when a geometry is created
  35723. */
  35724. onNewGeometryAddedObservable: Observable<Geometry>;
  35725. /**
  35726. * An event triggered when a geometry is removed
  35727. */
  35728. onGeometryRemovedObservable: Observable<Geometry>;
  35729. /**
  35730. * An event triggered when a transform node is created
  35731. */
  35732. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35733. /**
  35734. * An event triggered when a transform node is removed
  35735. */
  35736. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35737. /**
  35738. * An event triggered when a mesh is created
  35739. */
  35740. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35741. /**
  35742. * An event triggered when a mesh is removed
  35743. */
  35744. onMeshRemovedObservable: Observable<AbstractMesh>;
  35745. /**
  35746. * An event triggered when a skeleton is created
  35747. */
  35748. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35749. /**
  35750. * An event triggered when a skeleton is removed
  35751. */
  35752. onSkeletonRemovedObservable: Observable<Skeleton>;
  35753. /**
  35754. * An event triggered when a material is created
  35755. */
  35756. onNewMaterialAddedObservable: Observable<Material>;
  35757. /**
  35758. * An event triggered when a material is removed
  35759. */
  35760. onMaterialRemovedObservable: Observable<Material>;
  35761. /**
  35762. * An event triggered when a texture is created
  35763. */
  35764. onNewTextureAddedObservable: Observable<BaseTexture>;
  35765. /**
  35766. * An event triggered when a texture is removed
  35767. */
  35768. onTextureRemovedObservable: Observable<BaseTexture>;
  35769. /**
  35770. * An event triggered when render targets are about to be rendered
  35771. * Can happen multiple times per frame.
  35772. */
  35773. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35774. /**
  35775. * An event triggered when render targets were rendered.
  35776. * Can happen multiple times per frame.
  35777. */
  35778. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35779. /**
  35780. * An event triggered before calculating deterministic simulation step
  35781. */
  35782. onBeforeStepObservable: Observable<Scene>;
  35783. /**
  35784. * An event triggered after calculating deterministic simulation step
  35785. */
  35786. onAfterStepObservable: Observable<Scene>;
  35787. /**
  35788. * An event triggered when the activeCamera property is updated
  35789. */
  35790. onActiveCameraChanged: Observable<Scene>;
  35791. /**
  35792. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35793. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35794. * 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)
  35795. */
  35796. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35797. /**
  35798. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35799. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35800. * 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)
  35801. */
  35802. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35803. /**
  35804. * This Observable will when a mesh has been imported into the scene.
  35805. */
  35806. onMeshImportedObservable: Observable<AbstractMesh>;
  35807. /**
  35808. * This Observable will when an animation file has been imported into the scene.
  35809. */
  35810. onAnimationFileImportedObservable: Observable<Scene>;
  35811. /**
  35812. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35813. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35814. */
  35815. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35816. /** @hidden */
  35817. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35818. /**
  35819. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35820. */
  35821. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35822. /**
  35823. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35824. */
  35825. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35826. /**
  35827. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35828. */
  35829. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35830. /** Callback called when a pointer move is detected */
  35831. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35832. /** Callback called when a pointer down is detected */
  35833. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35834. /** Callback called when a pointer up is detected */
  35835. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35836. /** Callback called when a pointer pick is detected */
  35837. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35838. /**
  35839. * 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).
  35840. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35841. */
  35842. onPrePointerObservable: Observable<PointerInfoPre>;
  35843. /**
  35844. * Observable event triggered each time an input event is received from the rendering canvas
  35845. */
  35846. onPointerObservable: Observable<PointerInfo>;
  35847. /**
  35848. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35849. */
  35850. get unTranslatedPointer(): Vector2;
  35851. /**
  35852. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35853. */
  35854. static get DragMovementThreshold(): number;
  35855. static set DragMovementThreshold(value: number);
  35856. /**
  35857. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35858. */
  35859. static get LongPressDelay(): number;
  35860. static set LongPressDelay(value: number);
  35861. /**
  35862. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35863. */
  35864. static get DoubleClickDelay(): number;
  35865. static set DoubleClickDelay(value: number);
  35866. /** If you need to check double click without raising a single click at first click, enable this flag */
  35867. static get ExclusiveDoubleClickMode(): boolean;
  35868. static set ExclusiveDoubleClickMode(value: boolean);
  35869. /** @hidden */
  35870. _mirroredCameraPosition: Nullable<Vector3>;
  35871. /**
  35872. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35873. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35874. */
  35875. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35876. /**
  35877. * Observable event triggered each time an keyboard event is received from the hosting window
  35878. */
  35879. onKeyboardObservable: Observable<KeyboardInfo>;
  35880. private _useRightHandedSystem;
  35881. /**
  35882. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35883. */
  35884. set useRightHandedSystem(value: boolean);
  35885. get useRightHandedSystem(): boolean;
  35886. private _timeAccumulator;
  35887. private _currentStepId;
  35888. private _currentInternalStep;
  35889. /**
  35890. * Sets the step Id used by deterministic lock step
  35891. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35892. * @param newStepId defines the step Id
  35893. */
  35894. setStepId(newStepId: number): void;
  35895. /**
  35896. * Gets the step Id used by deterministic lock step
  35897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35898. * @returns the step Id
  35899. */
  35900. getStepId(): number;
  35901. /**
  35902. * Gets the internal step used by deterministic lock step
  35903. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35904. * @returns the internal step
  35905. */
  35906. getInternalStep(): number;
  35907. private _fogEnabled;
  35908. /**
  35909. * Gets or sets a boolean indicating if fog is enabled on this scene
  35910. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35911. * (Default is true)
  35912. */
  35913. set fogEnabled(value: boolean);
  35914. get fogEnabled(): boolean;
  35915. private _fogMode;
  35916. /**
  35917. * Gets or sets the fog mode to use
  35918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35919. * | mode | value |
  35920. * | --- | --- |
  35921. * | FOGMODE_NONE | 0 |
  35922. * | FOGMODE_EXP | 1 |
  35923. * | FOGMODE_EXP2 | 2 |
  35924. * | FOGMODE_LINEAR | 3 |
  35925. */
  35926. set fogMode(value: number);
  35927. get fogMode(): number;
  35928. /**
  35929. * Gets or sets the fog color to use
  35930. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35931. * (Default is Color3(0.2, 0.2, 0.3))
  35932. */
  35933. fogColor: Color3;
  35934. /**
  35935. * Gets or sets the fog density to use
  35936. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35937. * (Default is 0.1)
  35938. */
  35939. fogDensity: number;
  35940. /**
  35941. * Gets or sets the fog start distance to use
  35942. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35943. * (Default is 0)
  35944. */
  35945. fogStart: number;
  35946. /**
  35947. * Gets or sets the fog end distance to use
  35948. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35949. * (Default is 1000)
  35950. */
  35951. fogEnd: number;
  35952. private _shadowsEnabled;
  35953. /**
  35954. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35955. */
  35956. set shadowsEnabled(value: boolean);
  35957. get shadowsEnabled(): boolean;
  35958. private _lightsEnabled;
  35959. /**
  35960. * Gets or sets a boolean indicating if lights are enabled on this scene
  35961. */
  35962. set lightsEnabled(value: boolean);
  35963. get lightsEnabled(): boolean;
  35964. /** All of the active cameras added to this scene. */
  35965. activeCameras: Camera[];
  35966. /** @hidden */
  35967. _activeCamera: Nullable<Camera>;
  35968. /** Gets or sets the current active camera */
  35969. get activeCamera(): Nullable<Camera>;
  35970. set activeCamera(value: Nullable<Camera>);
  35971. private _defaultMaterial;
  35972. /** The default material used on meshes when no material is affected */
  35973. get defaultMaterial(): Material;
  35974. /** The default material used on meshes when no material is affected */
  35975. set defaultMaterial(value: Material);
  35976. private _texturesEnabled;
  35977. /**
  35978. * Gets or sets a boolean indicating if textures are enabled on this scene
  35979. */
  35980. set texturesEnabled(value: boolean);
  35981. get texturesEnabled(): boolean;
  35982. /**
  35983. * Gets or sets a boolean indicating if particles are enabled on this scene
  35984. */
  35985. particlesEnabled: boolean;
  35986. /**
  35987. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35988. */
  35989. spritesEnabled: boolean;
  35990. private _skeletonsEnabled;
  35991. /**
  35992. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35993. */
  35994. set skeletonsEnabled(value: boolean);
  35995. get skeletonsEnabled(): boolean;
  35996. /**
  35997. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35998. */
  35999. lensFlaresEnabled: boolean;
  36000. /**
  36001. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36002. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36003. */
  36004. collisionsEnabled: boolean;
  36005. private _collisionCoordinator;
  36006. /** @hidden */
  36007. get collisionCoordinator(): ICollisionCoordinator;
  36008. /**
  36009. * Defines the gravity applied to this scene (used only for collisions)
  36010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36011. */
  36012. gravity: Vector3;
  36013. /**
  36014. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36015. */
  36016. postProcessesEnabled: boolean;
  36017. /**
  36018. * The list of postprocesses added to the scene
  36019. */
  36020. postProcesses: PostProcess[];
  36021. /**
  36022. * Gets the current postprocess manager
  36023. */
  36024. postProcessManager: PostProcessManager;
  36025. /**
  36026. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36027. */
  36028. renderTargetsEnabled: boolean;
  36029. /**
  36030. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36031. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36032. */
  36033. dumpNextRenderTargets: boolean;
  36034. /**
  36035. * The list of user defined render targets added to the scene
  36036. */
  36037. customRenderTargets: RenderTargetTexture[];
  36038. /**
  36039. * Defines if texture loading must be delayed
  36040. * If true, textures will only be loaded when they need to be rendered
  36041. */
  36042. useDelayedTextureLoading: boolean;
  36043. /**
  36044. * Gets the list of meshes imported to the scene through SceneLoader
  36045. */
  36046. importedMeshesFiles: String[];
  36047. /**
  36048. * Gets or sets a boolean indicating if probes are enabled on this scene
  36049. */
  36050. probesEnabled: boolean;
  36051. /**
  36052. * Gets or sets the current offline provider to use to store scene data
  36053. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36054. */
  36055. offlineProvider: IOfflineProvider;
  36056. /**
  36057. * Gets or sets the action manager associated with the scene
  36058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36059. */
  36060. actionManager: AbstractActionManager;
  36061. private _meshesForIntersections;
  36062. /**
  36063. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36064. */
  36065. proceduralTexturesEnabled: boolean;
  36066. private _engine;
  36067. private _totalVertices;
  36068. /** @hidden */
  36069. _activeIndices: PerfCounter;
  36070. /** @hidden */
  36071. _activeParticles: PerfCounter;
  36072. /** @hidden */
  36073. _activeBones: PerfCounter;
  36074. private _animationRatio;
  36075. /** @hidden */
  36076. _animationTimeLast: number;
  36077. /** @hidden */
  36078. _animationTime: number;
  36079. /**
  36080. * Gets or sets a general scale for animation speed
  36081. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36082. */
  36083. animationTimeScale: number;
  36084. /** @hidden */
  36085. _cachedMaterial: Nullable<Material>;
  36086. /** @hidden */
  36087. _cachedEffect: Nullable<Effect>;
  36088. /** @hidden */
  36089. _cachedVisibility: Nullable<number>;
  36090. private _renderId;
  36091. private _frameId;
  36092. private _executeWhenReadyTimeoutId;
  36093. private _intermediateRendering;
  36094. private _viewUpdateFlag;
  36095. private _projectionUpdateFlag;
  36096. /** @hidden */
  36097. _toBeDisposed: Nullable<IDisposable>[];
  36098. private _activeRequests;
  36099. /** @hidden */
  36100. _pendingData: any[];
  36101. private _isDisposed;
  36102. /**
  36103. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36104. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36105. */
  36106. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36107. private _activeMeshes;
  36108. private _processedMaterials;
  36109. private _renderTargets;
  36110. /** @hidden */
  36111. _activeParticleSystems: SmartArray<IParticleSystem>;
  36112. private _activeSkeletons;
  36113. private _softwareSkinnedMeshes;
  36114. private _renderingManager;
  36115. /** @hidden */
  36116. _activeAnimatables: Animatable[];
  36117. private _transformMatrix;
  36118. private _sceneUbo;
  36119. /** @hidden */
  36120. _viewMatrix: Matrix;
  36121. private _projectionMatrix;
  36122. /** @hidden */
  36123. _forcedViewPosition: Nullable<Vector3>;
  36124. /** @hidden */
  36125. _frustumPlanes: Plane[];
  36126. /**
  36127. * Gets the list of frustum planes (built from the active camera)
  36128. */
  36129. get frustumPlanes(): Plane[];
  36130. /**
  36131. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36132. * This is useful if there are more lights that the maximum simulteanous authorized
  36133. */
  36134. requireLightSorting: boolean;
  36135. /** @hidden */
  36136. readonly useMaterialMeshMap: boolean;
  36137. /** @hidden */
  36138. readonly useClonedMeshMap: boolean;
  36139. private _externalData;
  36140. private _uid;
  36141. /**
  36142. * @hidden
  36143. * Backing store of defined scene components.
  36144. */
  36145. _components: ISceneComponent[];
  36146. /**
  36147. * @hidden
  36148. * Backing store of defined scene components.
  36149. */
  36150. _serializableComponents: ISceneSerializableComponent[];
  36151. /**
  36152. * List of components to register on the next registration step.
  36153. */
  36154. private _transientComponents;
  36155. /**
  36156. * Registers the transient components if needed.
  36157. */
  36158. private _registerTransientComponents;
  36159. /**
  36160. * @hidden
  36161. * Add a component to the scene.
  36162. * Note that the ccomponent could be registered on th next frame if this is called after
  36163. * the register component stage.
  36164. * @param component Defines the component to add to the scene
  36165. */
  36166. _addComponent(component: ISceneComponent): void;
  36167. /**
  36168. * @hidden
  36169. * Gets a component from the scene.
  36170. * @param name defines the name of the component to retrieve
  36171. * @returns the component or null if not present
  36172. */
  36173. _getComponent(name: string): Nullable<ISceneComponent>;
  36174. /**
  36175. * @hidden
  36176. * Defines the actions happening before camera updates.
  36177. */
  36178. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36179. /**
  36180. * @hidden
  36181. * Defines the actions happening before clear the canvas.
  36182. */
  36183. _beforeClearStage: Stage<SimpleStageAction>;
  36184. /**
  36185. * @hidden
  36186. * Defines the actions when collecting render targets for the frame.
  36187. */
  36188. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36189. /**
  36190. * @hidden
  36191. * Defines the actions happening for one camera in the frame.
  36192. */
  36193. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36194. /**
  36195. * @hidden
  36196. * Defines the actions happening during the per mesh ready checks.
  36197. */
  36198. _isReadyForMeshStage: Stage<MeshStageAction>;
  36199. /**
  36200. * @hidden
  36201. * Defines the actions happening before evaluate active mesh checks.
  36202. */
  36203. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36204. /**
  36205. * @hidden
  36206. * Defines the actions happening during the evaluate sub mesh checks.
  36207. */
  36208. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36209. /**
  36210. * @hidden
  36211. * Defines the actions happening during the active mesh stage.
  36212. */
  36213. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36214. /**
  36215. * @hidden
  36216. * Defines the actions happening during the per camera render target step.
  36217. */
  36218. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36219. /**
  36220. * @hidden
  36221. * Defines the actions happening just before the active camera is drawing.
  36222. */
  36223. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36224. /**
  36225. * @hidden
  36226. * Defines the actions happening just before a render target is drawing.
  36227. */
  36228. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36229. /**
  36230. * @hidden
  36231. * Defines the actions happening just before a rendering group is drawing.
  36232. */
  36233. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36234. /**
  36235. * @hidden
  36236. * Defines the actions happening just before a mesh is drawing.
  36237. */
  36238. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36239. /**
  36240. * @hidden
  36241. * Defines the actions happening just after a mesh has been drawn.
  36242. */
  36243. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36244. /**
  36245. * @hidden
  36246. * Defines the actions happening just after a rendering group has been drawn.
  36247. */
  36248. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36249. /**
  36250. * @hidden
  36251. * Defines the actions happening just after the active camera has been drawn.
  36252. */
  36253. _afterCameraDrawStage: Stage<CameraStageAction>;
  36254. /**
  36255. * @hidden
  36256. * Defines the actions happening just after a render target has been drawn.
  36257. */
  36258. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36259. /**
  36260. * @hidden
  36261. * Defines the actions happening just after rendering all cameras and computing intersections.
  36262. */
  36263. _afterRenderStage: Stage<SimpleStageAction>;
  36264. /**
  36265. * @hidden
  36266. * Defines the actions happening when a pointer move event happens.
  36267. */
  36268. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36269. /**
  36270. * @hidden
  36271. * Defines the actions happening when a pointer down event happens.
  36272. */
  36273. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36274. /**
  36275. * @hidden
  36276. * Defines the actions happening when a pointer up event happens.
  36277. */
  36278. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36279. /**
  36280. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36281. */
  36282. private geometriesByUniqueId;
  36283. /**
  36284. * Creates a new Scene
  36285. * @param engine defines the engine to use to render this scene
  36286. * @param options defines the scene options
  36287. */
  36288. constructor(engine: Engine, options?: SceneOptions);
  36289. /**
  36290. * Gets a string idenfifying the name of the class
  36291. * @returns "Scene" string
  36292. */
  36293. getClassName(): string;
  36294. private _defaultMeshCandidates;
  36295. /**
  36296. * @hidden
  36297. */
  36298. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36299. private _defaultSubMeshCandidates;
  36300. /**
  36301. * @hidden
  36302. */
  36303. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36304. /**
  36305. * Sets the default candidate providers for the scene.
  36306. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36307. * and getCollidingSubMeshCandidates to their default function
  36308. */
  36309. setDefaultCandidateProviders(): void;
  36310. /**
  36311. * Gets the mesh that is currently under the pointer
  36312. */
  36313. get meshUnderPointer(): Nullable<AbstractMesh>;
  36314. /**
  36315. * Gets or sets the current on-screen X position of the pointer
  36316. */
  36317. get pointerX(): number;
  36318. set pointerX(value: number);
  36319. /**
  36320. * Gets or sets the current on-screen Y position of the pointer
  36321. */
  36322. get pointerY(): number;
  36323. set pointerY(value: number);
  36324. /**
  36325. * Gets the cached material (ie. the latest rendered one)
  36326. * @returns the cached material
  36327. */
  36328. getCachedMaterial(): Nullable<Material>;
  36329. /**
  36330. * Gets the cached effect (ie. the latest rendered one)
  36331. * @returns the cached effect
  36332. */
  36333. getCachedEffect(): Nullable<Effect>;
  36334. /**
  36335. * Gets the cached visibility state (ie. the latest rendered one)
  36336. * @returns the cached visibility state
  36337. */
  36338. getCachedVisibility(): Nullable<number>;
  36339. /**
  36340. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36341. * @param material defines the current material
  36342. * @param effect defines the current effect
  36343. * @param visibility defines the current visibility state
  36344. * @returns true if one parameter is not cached
  36345. */
  36346. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36347. /**
  36348. * Gets the engine associated with the scene
  36349. * @returns an Engine
  36350. */
  36351. getEngine(): Engine;
  36352. /**
  36353. * Gets the total number of vertices rendered per frame
  36354. * @returns the total number of vertices rendered per frame
  36355. */
  36356. getTotalVertices(): number;
  36357. /**
  36358. * Gets the performance counter for total vertices
  36359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36360. */
  36361. get totalVerticesPerfCounter(): PerfCounter;
  36362. /**
  36363. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36364. * @returns the total number of active indices rendered per frame
  36365. */
  36366. getActiveIndices(): number;
  36367. /**
  36368. * Gets the performance counter for active indices
  36369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36370. */
  36371. get totalActiveIndicesPerfCounter(): PerfCounter;
  36372. /**
  36373. * Gets the total number of active particles rendered per frame
  36374. * @returns the total number of active particles rendered per frame
  36375. */
  36376. getActiveParticles(): number;
  36377. /**
  36378. * Gets the performance counter for active particles
  36379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36380. */
  36381. get activeParticlesPerfCounter(): PerfCounter;
  36382. /**
  36383. * Gets the total number of active bones rendered per frame
  36384. * @returns the total number of active bones rendered per frame
  36385. */
  36386. getActiveBones(): number;
  36387. /**
  36388. * Gets the performance counter for active bones
  36389. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36390. */
  36391. get activeBonesPerfCounter(): PerfCounter;
  36392. /**
  36393. * Gets the array of active meshes
  36394. * @returns an array of AbstractMesh
  36395. */
  36396. getActiveMeshes(): SmartArray<AbstractMesh>;
  36397. /**
  36398. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36399. * @returns a number
  36400. */
  36401. getAnimationRatio(): number;
  36402. /**
  36403. * Gets an unique Id for the current render phase
  36404. * @returns a number
  36405. */
  36406. getRenderId(): number;
  36407. /**
  36408. * Gets an unique Id for the current frame
  36409. * @returns a number
  36410. */
  36411. getFrameId(): number;
  36412. /** Call this function if you want to manually increment the render Id*/
  36413. incrementRenderId(): void;
  36414. private _createUbo;
  36415. /**
  36416. * Use this method to simulate a pointer move on a mesh
  36417. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36418. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36419. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36420. * @returns the current scene
  36421. */
  36422. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36423. /**
  36424. * Use this method to simulate a pointer down on a mesh
  36425. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36426. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36427. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36428. * @returns the current scene
  36429. */
  36430. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36431. /**
  36432. * Use this method to simulate a pointer up on a mesh
  36433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36436. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36437. * @returns the current scene
  36438. */
  36439. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36440. /**
  36441. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36442. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36443. * @returns true if the pointer was captured
  36444. */
  36445. isPointerCaptured(pointerId?: number): boolean;
  36446. /**
  36447. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36448. * @param attachUp defines if you want to attach events to pointerup
  36449. * @param attachDown defines if you want to attach events to pointerdown
  36450. * @param attachMove defines if you want to attach events to pointermove
  36451. */
  36452. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36453. /** Detaches all event handlers*/
  36454. detachControl(): void;
  36455. /**
  36456. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36457. * Delay loaded resources are not taking in account
  36458. * @return true if all required resources are ready
  36459. */
  36460. isReady(): boolean;
  36461. /** Resets all cached information relative to material (including effect and visibility) */
  36462. resetCachedMaterial(): void;
  36463. /**
  36464. * Registers a function to be called before every frame render
  36465. * @param func defines the function to register
  36466. */
  36467. registerBeforeRender(func: () => void): void;
  36468. /**
  36469. * Unregisters a function called before every frame render
  36470. * @param func defines the function to unregister
  36471. */
  36472. unregisterBeforeRender(func: () => void): void;
  36473. /**
  36474. * Registers a function to be called after every frame render
  36475. * @param func defines the function to register
  36476. */
  36477. registerAfterRender(func: () => void): void;
  36478. /**
  36479. * Unregisters a function called after every frame render
  36480. * @param func defines the function to unregister
  36481. */
  36482. unregisterAfterRender(func: () => void): void;
  36483. private _executeOnceBeforeRender;
  36484. /**
  36485. * The provided function will run before render once and will be disposed afterwards.
  36486. * A timeout delay can be provided so that the function will be executed in N ms.
  36487. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36488. * @param func The function to be executed.
  36489. * @param timeout optional delay in ms
  36490. */
  36491. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36492. /** @hidden */
  36493. _addPendingData(data: any): void;
  36494. /** @hidden */
  36495. _removePendingData(data: any): void;
  36496. /**
  36497. * Returns the number of items waiting to be loaded
  36498. * @returns the number of items waiting to be loaded
  36499. */
  36500. getWaitingItemsCount(): number;
  36501. /**
  36502. * Returns a boolean indicating if the scene is still loading data
  36503. */
  36504. get isLoading(): boolean;
  36505. /**
  36506. * Registers a function to be executed when the scene is ready
  36507. * @param {Function} func - the function to be executed
  36508. */
  36509. executeWhenReady(func: () => void): void;
  36510. /**
  36511. * Returns a promise that resolves when the scene is ready
  36512. * @returns A promise that resolves when the scene is ready
  36513. */
  36514. whenReadyAsync(): Promise<void>;
  36515. /** @hidden */
  36516. _checkIsReady(): void;
  36517. /**
  36518. * Gets all animatable attached to the scene
  36519. */
  36520. get animatables(): Animatable[];
  36521. /**
  36522. * Resets the last animation time frame.
  36523. * Useful to override when animations start running when loading a scene for the first time.
  36524. */
  36525. resetLastAnimationTimeFrame(): void;
  36526. /**
  36527. * Gets the current view matrix
  36528. * @returns a Matrix
  36529. */
  36530. getViewMatrix(): Matrix;
  36531. /**
  36532. * Gets the current projection matrix
  36533. * @returns a Matrix
  36534. */
  36535. getProjectionMatrix(): Matrix;
  36536. /**
  36537. * Gets the current transform matrix
  36538. * @returns a Matrix made of View * Projection
  36539. */
  36540. getTransformMatrix(): Matrix;
  36541. /**
  36542. * Sets the current transform matrix
  36543. * @param viewL defines the View matrix to use
  36544. * @param projectionL defines the Projection matrix to use
  36545. * @param viewR defines the right View matrix to use (if provided)
  36546. * @param projectionR defines the right Projection matrix to use (if provided)
  36547. */
  36548. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36549. /**
  36550. * Gets the uniform buffer used to store scene data
  36551. * @returns a UniformBuffer
  36552. */
  36553. getSceneUniformBuffer(): UniformBuffer;
  36554. /**
  36555. * Gets an unique (relatively to the current scene) Id
  36556. * @returns an unique number for the scene
  36557. */
  36558. getUniqueId(): number;
  36559. /**
  36560. * Add a mesh to the list of scene's meshes
  36561. * @param newMesh defines the mesh to add
  36562. * @param recursive if all child meshes should also be added to the scene
  36563. */
  36564. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36565. /**
  36566. * Remove a mesh for the list of scene's meshes
  36567. * @param toRemove defines the mesh to remove
  36568. * @param recursive if all child meshes should also be removed from the scene
  36569. * @returns the index where the mesh was in the mesh list
  36570. */
  36571. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36572. /**
  36573. * Add a transform node to the list of scene's transform nodes
  36574. * @param newTransformNode defines the transform node to add
  36575. */
  36576. addTransformNode(newTransformNode: TransformNode): void;
  36577. /**
  36578. * Remove a transform node for the list of scene's transform nodes
  36579. * @param toRemove defines the transform node to remove
  36580. * @returns the index where the transform node was in the transform node list
  36581. */
  36582. removeTransformNode(toRemove: TransformNode): number;
  36583. /**
  36584. * Remove a skeleton for the list of scene's skeletons
  36585. * @param toRemove defines the skeleton to remove
  36586. * @returns the index where the skeleton was in the skeleton list
  36587. */
  36588. removeSkeleton(toRemove: Skeleton): number;
  36589. /**
  36590. * Remove a morph target for the list of scene's morph targets
  36591. * @param toRemove defines the morph target to remove
  36592. * @returns the index where the morph target was in the morph target list
  36593. */
  36594. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36595. /**
  36596. * Remove a light for the list of scene's lights
  36597. * @param toRemove defines the light to remove
  36598. * @returns the index where the light was in the light list
  36599. */
  36600. removeLight(toRemove: Light): number;
  36601. /**
  36602. * Remove a camera for the list of scene's cameras
  36603. * @param toRemove defines the camera to remove
  36604. * @returns the index where the camera was in the camera list
  36605. */
  36606. removeCamera(toRemove: Camera): number;
  36607. /**
  36608. * Remove a particle system for the list of scene's particle systems
  36609. * @param toRemove defines the particle system to remove
  36610. * @returns the index where the particle system was in the particle system list
  36611. */
  36612. removeParticleSystem(toRemove: IParticleSystem): number;
  36613. /**
  36614. * Remove a animation for the list of scene's animations
  36615. * @param toRemove defines the animation to remove
  36616. * @returns the index where the animation was in the animation list
  36617. */
  36618. removeAnimation(toRemove: Animation): number;
  36619. /**
  36620. * Will stop the animation of the given target
  36621. * @param target - the target
  36622. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36623. * @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)
  36624. */
  36625. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36626. /**
  36627. * Removes the given animation group from this scene.
  36628. * @param toRemove The animation group to remove
  36629. * @returns The index of the removed animation group
  36630. */
  36631. removeAnimationGroup(toRemove: AnimationGroup): number;
  36632. /**
  36633. * Removes the given multi-material from this scene.
  36634. * @param toRemove The multi-material to remove
  36635. * @returns The index of the removed multi-material
  36636. */
  36637. removeMultiMaterial(toRemove: MultiMaterial): number;
  36638. /**
  36639. * Removes the given material from this scene.
  36640. * @param toRemove The material to remove
  36641. * @returns The index of the removed material
  36642. */
  36643. removeMaterial(toRemove: Material): number;
  36644. /**
  36645. * Removes the given action manager from this scene.
  36646. * @param toRemove The action manager to remove
  36647. * @returns The index of the removed action manager
  36648. */
  36649. removeActionManager(toRemove: AbstractActionManager): number;
  36650. /**
  36651. * Removes the given texture from this scene.
  36652. * @param toRemove The texture to remove
  36653. * @returns The index of the removed texture
  36654. */
  36655. removeTexture(toRemove: BaseTexture): number;
  36656. /**
  36657. * Adds the given light to this scene
  36658. * @param newLight The light to add
  36659. */
  36660. addLight(newLight: Light): void;
  36661. /**
  36662. * Sorts the list list based on light priorities
  36663. */
  36664. sortLightsByPriority(): void;
  36665. /**
  36666. * Adds the given camera to this scene
  36667. * @param newCamera The camera to add
  36668. */
  36669. addCamera(newCamera: Camera): void;
  36670. /**
  36671. * Adds the given skeleton to this scene
  36672. * @param newSkeleton The skeleton to add
  36673. */
  36674. addSkeleton(newSkeleton: Skeleton): void;
  36675. /**
  36676. * Adds the given particle system to this scene
  36677. * @param newParticleSystem The particle system to add
  36678. */
  36679. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36680. /**
  36681. * Adds the given animation to this scene
  36682. * @param newAnimation The animation to add
  36683. */
  36684. addAnimation(newAnimation: Animation): void;
  36685. /**
  36686. * Adds the given animation group to this scene.
  36687. * @param newAnimationGroup The animation group to add
  36688. */
  36689. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36690. /**
  36691. * Adds the given multi-material to this scene
  36692. * @param newMultiMaterial The multi-material to add
  36693. */
  36694. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36695. /**
  36696. * Adds the given material to this scene
  36697. * @param newMaterial The material to add
  36698. */
  36699. addMaterial(newMaterial: Material): void;
  36700. /**
  36701. * Adds the given morph target to this scene
  36702. * @param newMorphTargetManager The morph target to add
  36703. */
  36704. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36705. /**
  36706. * Adds the given geometry to this scene
  36707. * @param newGeometry The geometry to add
  36708. */
  36709. addGeometry(newGeometry: Geometry): void;
  36710. /**
  36711. * Adds the given action manager to this scene
  36712. * @param newActionManager The action manager to add
  36713. */
  36714. addActionManager(newActionManager: AbstractActionManager): void;
  36715. /**
  36716. * Adds the given texture to this scene.
  36717. * @param newTexture The texture to add
  36718. */
  36719. addTexture(newTexture: BaseTexture): void;
  36720. /**
  36721. * Switch active camera
  36722. * @param newCamera defines the new active camera
  36723. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36724. */
  36725. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36726. /**
  36727. * sets the active camera of the scene using its ID
  36728. * @param id defines the camera's ID
  36729. * @return the new active camera or null if none found.
  36730. */
  36731. setActiveCameraByID(id: string): Nullable<Camera>;
  36732. /**
  36733. * sets the active camera of the scene using its name
  36734. * @param name defines the camera's name
  36735. * @returns the new active camera or null if none found.
  36736. */
  36737. setActiveCameraByName(name: string): Nullable<Camera>;
  36738. /**
  36739. * get an animation group using its name
  36740. * @param name defines the material's name
  36741. * @return the animation group or null if none found.
  36742. */
  36743. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36744. /**
  36745. * Get a material using its unique id
  36746. * @param uniqueId defines the material's unique id
  36747. * @return the material or null if none found.
  36748. */
  36749. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36750. /**
  36751. * get a material using its id
  36752. * @param id defines the material's ID
  36753. * @return the material or null if none found.
  36754. */
  36755. getMaterialByID(id: string): Nullable<Material>;
  36756. /**
  36757. * Gets a the last added material using a given id
  36758. * @param id defines the material's ID
  36759. * @return the last material with the given id or null if none found.
  36760. */
  36761. getLastMaterialByID(id: string): Nullable<Material>;
  36762. /**
  36763. * Gets a material using its name
  36764. * @param name defines the material's name
  36765. * @return the material or null if none found.
  36766. */
  36767. getMaterialByName(name: string): Nullable<Material>;
  36768. /**
  36769. * Get a texture using its unique id
  36770. * @param uniqueId defines the texture's unique id
  36771. * @return the texture or null if none found.
  36772. */
  36773. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36774. /**
  36775. * Gets a camera using its id
  36776. * @param id defines the id to look for
  36777. * @returns the camera or null if not found
  36778. */
  36779. getCameraByID(id: string): Nullable<Camera>;
  36780. /**
  36781. * Gets a camera using its unique id
  36782. * @param uniqueId defines the unique id to look for
  36783. * @returns the camera or null if not found
  36784. */
  36785. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36786. /**
  36787. * Gets a camera using its name
  36788. * @param name defines the camera's name
  36789. * @return the camera or null if none found.
  36790. */
  36791. getCameraByName(name: string): Nullable<Camera>;
  36792. /**
  36793. * Gets a bone using its id
  36794. * @param id defines the bone's id
  36795. * @return the bone or null if not found
  36796. */
  36797. getBoneByID(id: string): Nullable<Bone>;
  36798. /**
  36799. * Gets a bone using its id
  36800. * @param name defines the bone's name
  36801. * @return the bone or null if not found
  36802. */
  36803. getBoneByName(name: string): Nullable<Bone>;
  36804. /**
  36805. * Gets a light node using its name
  36806. * @param name defines the the light's name
  36807. * @return the light or null if none found.
  36808. */
  36809. getLightByName(name: string): Nullable<Light>;
  36810. /**
  36811. * Gets a light node using its id
  36812. * @param id defines the light's id
  36813. * @return the light or null if none found.
  36814. */
  36815. getLightByID(id: string): Nullable<Light>;
  36816. /**
  36817. * Gets a light node using its scene-generated unique ID
  36818. * @param uniqueId defines the light's unique id
  36819. * @return the light or null if none found.
  36820. */
  36821. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36822. /**
  36823. * Gets a particle system by id
  36824. * @param id defines the particle system id
  36825. * @return the corresponding system or null if none found
  36826. */
  36827. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36828. /**
  36829. * Gets a geometry using its ID
  36830. * @param id defines the geometry's id
  36831. * @return the geometry or null if none found.
  36832. */
  36833. getGeometryByID(id: string): Nullable<Geometry>;
  36834. private _getGeometryByUniqueID;
  36835. /**
  36836. * Add a new geometry to this scene
  36837. * @param geometry defines the geometry to be added to the scene.
  36838. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36839. * @return a boolean defining if the geometry was added or not
  36840. */
  36841. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36842. /**
  36843. * Removes an existing geometry
  36844. * @param geometry defines the geometry to be removed from the scene
  36845. * @return a boolean defining if the geometry was removed or not
  36846. */
  36847. removeGeometry(geometry: Geometry): boolean;
  36848. /**
  36849. * Gets the list of geometries attached to the scene
  36850. * @returns an array of Geometry
  36851. */
  36852. getGeometries(): Geometry[];
  36853. /**
  36854. * Gets the first added mesh found of a given ID
  36855. * @param id defines the id to search for
  36856. * @return the mesh found or null if not found at all
  36857. */
  36858. getMeshByID(id: string): Nullable<AbstractMesh>;
  36859. /**
  36860. * Gets a list of meshes using their id
  36861. * @param id defines the id to search for
  36862. * @returns a list of meshes
  36863. */
  36864. getMeshesByID(id: string): Array<AbstractMesh>;
  36865. /**
  36866. * Gets the first added transform node found of a given ID
  36867. * @param id defines the id to search for
  36868. * @return the found transform node or null if not found at all.
  36869. */
  36870. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36871. /**
  36872. * Gets a transform node with its auto-generated unique id
  36873. * @param uniqueId efines the unique id to search for
  36874. * @return the found transform node or null if not found at all.
  36875. */
  36876. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36877. /**
  36878. * Gets a list of transform nodes using their id
  36879. * @param id defines the id to search for
  36880. * @returns a list of transform nodes
  36881. */
  36882. getTransformNodesByID(id: string): Array<TransformNode>;
  36883. /**
  36884. * Gets a mesh with its auto-generated unique id
  36885. * @param uniqueId defines the unique id to search for
  36886. * @return the found mesh or null if not found at all.
  36887. */
  36888. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36889. /**
  36890. * Gets a the last added mesh using a given id
  36891. * @param id defines the id to search for
  36892. * @return the found mesh or null if not found at all.
  36893. */
  36894. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36895. /**
  36896. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36897. * @param id defines the id to search for
  36898. * @return the found node or null if not found at all
  36899. */
  36900. getLastEntryByID(id: string): Nullable<Node>;
  36901. /**
  36902. * Gets a node (Mesh, Camera, Light) using a given id
  36903. * @param id defines the id to search for
  36904. * @return the found node or null if not found at all
  36905. */
  36906. getNodeByID(id: string): Nullable<Node>;
  36907. /**
  36908. * Gets a node (Mesh, Camera, Light) using a given name
  36909. * @param name defines the name to search for
  36910. * @return the found node or null if not found at all.
  36911. */
  36912. getNodeByName(name: string): Nullable<Node>;
  36913. /**
  36914. * Gets a mesh using a given name
  36915. * @param name defines the name to search for
  36916. * @return the found mesh or null if not found at all.
  36917. */
  36918. getMeshByName(name: string): Nullable<AbstractMesh>;
  36919. /**
  36920. * Gets a transform node using a given name
  36921. * @param name defines the name to search for
  36922. * @return the found transform node or null if not found at all.
  36923. */
  36924. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36925. /**
  36926. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36927. * @param id defines the id to search for
  36928. * @return the found skeleton or null if not found at all.
  36929. */
  36930. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36931. /**
  36932. * Gets a skeleton using a given auto generated unique id
  36933. * @param uniqueId defines the unique id to search for
  36934. * @return the found skeleton or null if not found at all.
  36935. */
  36936. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36937. /**
  36938. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36939. * @param id defines the id to search for
  36940. * @return the found skeleton or null if not found at all.
  36941. */
  36942. getSkeletonById(id: string): Nullable<Skeleton>;
  36943. /**
  36944. * Gets a skeleton using a given name
  36945. * @param name defines the name to search for
  36946. * @return the found skeleton or null if not found at all.
  36947. */
  36948. getSkeletonByName(name: string): Nullable<Skeleton>;
  36949. /**
  36950. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36951. * @param id defines the id to search for
  36952. * @return the found morph target manager or null if not found at all.
  36953. */
  36954. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36955. /**
  36956. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36957. * @param id defines the id to search for
  36958. * @return the found morph target or null if not found at all.
  36959. */
  36960. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36961. /**
  36962. * Gets a boolean indicating if the given mesh is active
  36963. * @param mesh defines the mesh to look for
  36964. * @returns true if the mesh is in the active list
  36965. */
  36966. isActiveMesh(mesh: AbstractMesh): boolean;
  36967. /**
  36968. * Return a unique id as a string which can serve as an identifier for the scene
  36969. */
  36970. get uid(): string;
  36971. /**
  36972. * Add an externaly attached data from its key.
  36973. * This method call will fail and return false, if such key already exists.
  36974. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36975. * @param key the unique key that identifies the data
  36976. * @param data the data object to associate to the key for this Engine instance
  36977. * @return true if no such key were already present and the data was added successfully, false otherwise
  36978. */
  36979. addExternalData<T>(key: string, data: T): boolean;
  36980. /**
  36981. * Get an externaly attached data from its key
  36982. * @param key the unique key that identifies the data
  36983. * @return the associated data, if present (can be null), or undefined if not present
  36984. */
  36985. getExternalData<T>(key: string): Nullable<T>;
  36986. /**
  36987. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36988. * @param key the unique key that identifies the data
  36989. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36990. * @return the associated data, can be null if the factory returned null.
  36991. */
  36992. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36993. /**
  36994. * Remove an externaly attached data from the Engine instance
  36995. * @param key the unique key that identifies the data
  36996. * @return true if the data was successfully removed, false if it doesn't exist
  36997. */
  36998. removeExternalData(key: string): boolean;
  36999. private _evaluateSubMesh;
  37000. /**
  37001. * Clear the processed materials smart array preventing retention point in material dispose.
  37002. */
  37003. freeProcessedMaterials(): void;
  37004. private _preventFreeActiveMeshesAndRenderingGroups;
  37005. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37006. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37007. * when disposing several meshes in a row or a hierarchy of meshes.
  37008. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37009. */
  37010. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37011. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37012. /**
  37013. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37014. */
  37015. freeActiveMeshes(): void;
  37016. /**
  37017. * Clear the info related to rendering groups preventing retention points during dispose.
  37018. */
  37019. freeRenderingGroups(): void;
  37020. /** @hidden */
  37021. _isInIntermediateRendering(): boolean;
  37022. /**
  37023. * Lambda returning the list of potentially active meshes.
  37024. */
  37025. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37026. /**
  37027. * Lambda returning the list of potentially active sub meshes.
  37028. */
  37029. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37030. /**
  37031. * Lambda returning the list of potentially intersecting sub meshes.
  37032. */
  37033. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37034. /**
  37035. * Lambda returning the list of potentially colliding sub meshes.
  37036. */
  37037. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37038. private _activeMeshesFrozen;
  37039. private _skipEvaluateActiveMeshesCompletely;
  37040. /**
  37041. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37042. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37043. * @returns the current scene
  37044. */
  37045. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37046. /**
  37047. * Use this function to restart evaluating active meshes on every frame
  37048. * @returns the current scene
  37049. */
  37050. unfreezeActiveMeshes(): Scene;
  37051. private _evaluateActiveMeshes;
  37052. private _activeMesh;
  37053. /**
  37054. * Update the transform matrix to update from the current active camera
  37055. * @param force defines a boolean used to force the update even if cache is up to date
  37056. */
  37057. updateTransformMatrix(force?: boolean): void;
  37058. private _bindFrameBuffer;
  37059. /** @hidden */
  37060. _allowPostProcessClearColor: boolean;
  37061. /** @hidden */
  37062. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37063. private _processSubCameras;
  37064. private _checkIntersections;
  37065. /** @hidden */
  37066. _advancePhysicsEngineStep(step: number): void;
  37067. /**
  37068. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37069. */
  37070. getDeterministicFrameTime: () => number;
  37071. /** @hidden */
  37072. _animate(): void;
  37073. /** Execute all animations (for a frame) */
  37074. animate(): void;
  37075. /**
  37076. * Render the scene
  37077. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37078. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37079. */
  37080. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37081. /**
  37082. * Freeze all materials
  37083. * A frozen material will not be updatable but should be faster to render
  37084. */
  37085. freezeMaterials(): void;
  37086. /**
  37087. * Unfreeze all materials
  37088. * A frozen material will not be updatable but should be faster to render
  37089. */
  37090. unfreezeMaterials(): void;
  37091. /**
  37092. * Releases all held ressources
  37093. */
  37094. dispose(): void;
  37095. /**
  37096. * Gets if the scene is already disposed
  37097. */
  37098. get isDisposed(): boolean;
  37099. /**
  37100. * Call this function to reduce memory footprint of the scene.
  37101. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37102. */
  37103. clearCachedVertexData(): void;
  37104. /**
  37105. * This function will remove the local cached buffer data from texture.
  37106. * It will save memory but will prevent the texture from being rebuilt
  37107. */
  37108. cleanCachedTextureBuffer(): void;
  37109. /**
  37110. * Get the world extend vectors with an optional filter
  37111. *
  37112. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37113. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37114. */
  37115. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37116. min: Vector3;
  37117. max: Vector3;
  37118. };
  37119. /**
  37120. * Creates a ray that can be used to pick in the scene
  37121. * @param x defines the x coordinate of the origin (on-screen)
  37122. * @param y defines the y coordinate of the origin (on-screen)
  37123. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37124. * @param camera defines the camera to use for the picking
  37125. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37126. * @returns a Ray
  37127. */
  37128. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37129. /**
  37130. * Creates a ray that can be used to pick in the scene
  37131. * @param x defines the x coordinate of the origin (on-screen)
  37132. * @param y defines the y coordinate of the origin (on-screen)
  37133. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37134. * @param result defines the ray where to store the picking ray
  37135. * @param camera defines the camera to use for the picking
  37136. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37137. * @returns the current scene
  37138. */
  37139. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37140. /**
  37141. * Creates a ray that can be used to pick in the scene
  37142. * @param x defines the x coordinate of the origin (on-screen)
  37143. * @param y defines the y coordinate of the origin (on-screen)
  37144. * @param camera defines the camera to use for the picking
  37145. * @returns a Ray
  37146. */
  37147. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37148. /**
  37149. * Creates a ray that can be used to pick in the scene
  37150. * @param x defines the x coordinate of the origin (on-screen)
  37151. * @param y defines the y coordinate of the origin (on-screen)
  37152. * @param result defines the ray where to store the picking ray
  37153. * @param camera defines the camera to use for the picking
  37154. * @returns the current scene
  37155. */
  37156. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37157. /** Launch a ray to try to pick a mesh in the scene
  37158. * @param x position on screen
  37159. * @param y position on screen
  37160. * @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
  37161. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37162. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37163. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37164. * @returns a PickingInfo
  37165. */
  37166. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37167. /** Use the given ray to pick a mesh in the scene
  37168. * @param ray The ray to use to pick meshes
  37169. * @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
  37170. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37172. * @returns a PickingInfo
  37173. */
  37174. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37175. /**
  37176. * Launch a ray to try to pick a mesh in the scene
  37177. * @param x X position on screen
  37178. * @param y Y position on screen
  37179. * @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
  37180. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37181. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37182. * @returns an array of PickingInfo
  37183. */
  37184. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37185. /**
  37186. * Launch a ray to try to pick a mesh in the scene
  37187. * @param ray Ray to use
  37188. * @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
  37189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37190. * @returns an array of PickingInfo
  37191. */
  37192. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37193. /**
  37194. * Force the value of meshUnderPointer
  37195. * @param mesh defines the mesh to use
  37196. */
  37197. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37198. /**
  37199. * Gets the mesh under the pointer
  37200. * @returns a Mesh or null if no mesh is under the pointer
  37201. */
  37202. getPointerOverMesh(): Nullable<AbstractMesh>;
  37203. /** @hidden */
  37204. _rebuildGeometries(): void;
  37205. /** @hidden */
  37206. _rebuildTextures(): void;
  37207. private _getByTags;
  37208. /**
  37209. * Get a list of meshes by tags
  37210. * @param tagsQuery defines the tags query to use
  37211. * @param forEach defines a predicate used to filter results
  37212. * @returns an array of Mesh
  37213. */
  37214. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37215. /**
  37216. * Get a list of cameras by tags
  37217. * @param tagsQuery defines the tags query to use
  37218. * @param forEach defines a predicate used to filter results
  37219. * @returns an array of Camera
  37220. */
  37221. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37222. /**
  37223. * Get a list of lights by tags
  37224. * @param tagsQuery defines the tags query to use
  37225. * @param forEach defines a predicate used to filter results
  37226. * @returns an array of Light
  37227. */
  37228. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37229. /**
  37230. * Get a list of materials by tags
  37231. * @param tagsQuery defines the tags query to use
  37232. * @param forEach defines a predicate used to filter results
  37233. * @returns an array of Material
  37234. */
  37235. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37236. /**
  37237. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37238. * This allowed control for front to back rendering or reversly depending of the special needs.
  37239. *
  37240. * @param renderingGroupId The rendering group id corresponding to its index
  37241. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37242. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37243. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37244. */
  37245. 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;
  37246. /**
  37247. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37248. *
  37249. * @param renderingGroupId The rendering group id corresponding to its index
  37250. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37251. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37252. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37253. */
  37254. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37255. /**
  37256. * Gets the current auto clear configuration for one rendering group of the rendering
  37257. * manager.
  37258. * @param index the rendering group index to get the information for
  37259. * @returns The auto clear setup for the requested rendering group
  37260. */
  37261. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37262. private _blockMaterialDirtyMechanism;
  37263. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37264. get blockMaterialDirtyMechanism(): boolean;
  37265. set blockMaterialDirtyMechanism(value: boolean);
  37266. /**
  37267. * Will flag all materials as dirty to trigger new shader compilation
  37268. * @param flag defines the flag used to specify which material part must be marked as dirty
  37269. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37270. */
  37271. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37272. /** @hidden */
  37273. _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;
  37274. /** @hidden */
  37275. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37276. /** @hidden */
  37277. _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;
  37278. /** @hidden */
  37279. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37280. /** @hidden */
  37281. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37282. /** @hidden */
  37283. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37284. }
  37285. }
  37286. declare module BABYLON {
  37287. /**
  37288. * Set of assets to keep when moving a scene into an asset container.
  37289. */
  37290. export class KeepAssets extends AbstractScene {
  37291. }
  37292. /**
  37293. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37294. */
  37295. export class InstantiatedEntries {
  37296. /**
  37297. * List of new root nodes (eg. nodes with no parent)
  37298. */
  37299. rootNodes: TransformNode[];
  37300. /**
  37301. * List of new skeletons
  37302. */
  37303. skeletons: Skeleton[];
  37304. /**
  37305. * List of new animation groups
  37306. */
  37307. animationGroups: AnimationGroup[];
  37308. }
  37309. /**
  37310. * Container with a set of assets that can be added or removed from a scene.
  37311. */
  37312. export class AssetContainer extends AbstractScene {
  37313. private _wasAddedToScene;
  37314. /**
  37315. * The scene the AssetContainer belongs to.
  37316. */
  37317. scene: Scene;
  37318. /**
  37319. * Instantiates an AssetContainer.
  37320. * @param scene The scene the AssetContainer belongs to.
  37321. */
  37322. constructor(scene: Scene);
  37323. /**
  37324. * Instantiate or clone all meshes and add the new ones to the scene.
  37325. * Skeletons and animation groups will all be cloned
  37326. * @param nameFunction defines an optional function used to get new names for clones
  37327. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37328. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37329. */
  37330. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37331. /**
  37332. * Adds all the assets from the container to the scene.
  37333. */
  37334. addAllToScene(): void;
  37335. /**
  37336. * Removes all the assets in the container from the scene
  37337. */
  37338. removeAllFromScene(): void;
  37339. /**
  37340. * Disposes all the assets in the container
  37341. */
  37342. dispose(): void;
  37343. private _moveAssets;
  37344. /**
  37345. * Removes all the assets contained in the scene and adds them to the container.
  37346. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37347. */
  37348. moveAllFromScene(keepAssets?: KeepAssets): void;
  37349. /**
  37350. * 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.
  37351. * @returns the root mesh
  37352. */
  37353. createRootMesh(): Mesh;
  37354. /**
  37355. * Merge animations from this asset container into a scene
  37356. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37357. * @param animatables set of animatables to retarget to a node from the scene
  37358. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37359. */
  37360. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37361. }
  37362. }
  37363. declare module BABYLON {
  37364. /**
  37365. * Defines how the parser contract is defined.
  37366. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37367. */
  37368. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37369. /**
  37370. * Defines how the individual parser contract is defined.
  37371. * These parser can parse an individual asset
  37372. */
  37373. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37374. /**
  37375. * Base class of the scene acting as a container for the different elements composing a scene.
  37376. * This class is dynamically extended by the different components of the scene increasing
  37377. * flexibility and reducing coupling
  37378. */
  37379. export abstract class AbstractScene {
  37380. /**
  37381. * Stores the list of available parsers in the application.
  37382. */
  37383. private static _BabylonFileParsers;
  37384. /**
  37385. * Stores the list of available individual parsers in the application.
  37386. */
  37387. private static _IndividualBabylonFileParsers;
  37388. /**
  37389. * Adds a parser in the list of available ones
  37390. * @param name Defines the name of the parser
  37391. * @param parser Defines the parser to add
  37392. */
  37393. static AddParser(name: string, parser: BabylonFileParser): void;
  37394. /**
  37395. * Gets a general parser from the list of avaialble ones
  37396. * @param name Defines the name of the parser
  37397. * @returns the requested parser or null
  37398. */
  37399. static GetParser(name: string): Nullable<BabylonFileParser>;
  37400. /**
  37401. * Adds n individual parser in the list of available ones
  37402. * @param name Defines the name of the parser
  37403. * @param parser Defines the parser to add
  37404. */
  37405. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37406. /**
  37407. * Gets an individual parser from the list of avaialble ones
  37408. * @param name Defines the name of the parser
  37409. * @returns the requested parser or null
  37410. */
  37411. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37412. /**
  37413. * Parser json data and populate both a scene and its associated container object
  37414. * @param jsonData Defines the data to parse
  37415. * @param scene Defines the scene to parse the data for
  37416. * @param container Defines the container attached to the parsing sequence
  37417. * @param rootUrl Defines the root url of the data
  37418. */
  37419. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37420. /**
  37421. * Gets the list of root nodes (ie. nodes with no parent)
  37422. */
  37423. rootNodes: Node[];
  37424. /** All of the cameras added to this scene
  37425. * @see http://doc.babylonjs.com/babylon101/cameras
  37426. */
  37427. cameras: Camera[];
  37428. /**
  37429. * All of the lights added to this scene
  37430. * @see http://doc.babylonjs.com/babylon101/lights
  37431. */
  37432. lights: Light[];
  37433. /**
  37434. * All of the (abstract) meshes added to this scene
  37435. */
  37436. meshes: AbstractMesh[];
  37437. /**
  37438. * The list of skeletons added to the scene
  37439. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37440. */
  37441. skeletons: Skeleton[];
  37442. /**
  37443. * All of the particle systems added to this scene
  37444. * @see http://doc.babylonjs.com/babylon101/particles
  37445. */
  37446. particleSystems: IParticleSystem[];
  37447. /**
  37448. * Gets a list of Animations associated with the scene
  37449. */
  37450. animations: Animation[];
  37451. /**
  37452. * All of the animation groups added to this scene
  37453. * @see http://doc.babylonjs.com/how_to/group
  37454. */
  37455. animationGroups: AnimationGroup[];
  37456. /**
  37457. * All of the multi-materials added to this scene
  37458. * @see http://doc.babylonjs.com/how_to/multi_materials
  37459. */
  37460. multiMaterials: MultiMaterial[];
  37461. /**
  37462. * All of the materials added to this scene
  37463. * In the context of a Scene, it is not supposed to be modified manually.
  37464. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37465. * Note also that the order of the Material within the array is not significant and might change.
  37466. * @see http://doc.babylonjs.com/babylon101/materials
  37467. */
  37468. materials: Material[];
  37469. /**
  37470. * The list of morph target managers added to the scene
  37471. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37472. */
  37473. morphTargetManagers: MorphTargetManager[];
  37474. /**
  37475. * The list of geometries used in the scene.
  37476. */
  37477. geometries: Geometry[];
  37478. /**
  37479. * All of the tranform nodes added to this scene
  37480. * In the context of a Scene, it is not supposed to be modified manually.
  37481. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37482. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37483. * @see http://doc.babylonjs.com/how_to/transformnode
  37484. */
  37485. transformNodes: TransformNode[];
  37486. /**
  37487. * ActionManagers available on the scene.
  37488. */
  37489. actionManagers: AbstractActionManager[];
  37490. /**
  37491. * Textures to keep.
  37492. */
  37493. textures: BaseTexture[];
  37494. /**
  37495. * Environment texture for the scene
  37496. */
  37497. environmentTexture: Nullable<BaseTexture>;
  37498. /**
  37499. * @returns all meshes, lights, cameras, transformNodes and bones
  37500. */
  37501. getNodes(): Array<Node>;
  37502. }
  37503. }
  37504. declare module BABYLON {
  37505. /**
  37506. * Interface used to define options for Sound class
  37507. */
  37508. export interface ISoundOptions {
  37509. /**
  37510. * Does the sound autoplay once loaded.
  37511. */
  37512. autoplay?: boolean;
  37513. /**
  37514. * Does the sound loop after it finishes playing once.
  37515. */
  37516. loop?: boolean;
  37517. /**
  37518. * Sound's volume
  37519. */
  37520. volume?: number;
  37521. /**
  37522. * Is it a spatial sound?
  37523. */
  37524. spatialSound?: boolean;
  37525. /**
  37526. * Maximum distance to hear that sound
  37527. */
  37528. maxDistance?: number;
  37529. /**
  37530. * Uses user defined attenuation function
  37531. */
  37532. useCustomAttenuation?: boolean;
  37533. /**
  37534. * Define the roll off factor of spatial sounds.
  37535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37536. */
  37537. rolloffFactor?: number;
  37538. /**
  37539. * Define the reference distance the sound should be heard perfectly.
  37540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37541. */
  37542. refDistance?: number;
  37543. /**
  37544. * Define the distance attenuation model the sound will follow.
  37545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37546. */
  37547. distanceModel?: string;
  37548. /**
  37549. * Defines the playback speed (1 by default)
  37550. */
  37551. playbackRate?: number;
  37552. /**
  37553. * Defines if the sound is from a streaming source
  37554. */
  37555. streaming?: boolean;
  37556. /**
  37557. * Defines an optional length (in seconds) inside the sound file
  37558. */
  37559. length?: number;
  37560. /**
  37561. * Defines an optional offset (in seconds) inside the sound file
  37562. */
  37563. offset?: number;
  37564. /**
  37565. * If true, URLs will not be required to state the audio file codec to use.
  37566. */
  37567. skipCodecCheck?: boolean;
  37568. }
  37569. /**
  37570. * Defines a sound that can be played in the application.
  37571. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37573. */
  37574. export class Sound {
  37575. /**
  37576. * The name of the sound in the scene.
  37577. */
  37578. name: string;
  37579. /**
  37580. * Does the sound autoplay once loaded.
  37581. */
  37582. autoplay: boolean;
  37583. /**
  37584. * Does the sound loop after it finishes playing once.
  37585. */
  37586. loop: boolean;
  37587. /**
  37588. * Does the sound use a custom attenuation curve to simulate the falloff
  37589. * happening when the source gets further away from the camera.
  37590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37591. */
  37592. useCustomAttenuation: boolean;
  37593. /**
  37594. * The sound track id this sound belongs to.
  37595. */
  37596. soundTrackId: number;
  37597. /**
  37598. * Is this sound currently played.
  37599. */
  37600. isPlaying: boolean;
  37601. /**
  37602. * Is this sound currently paused.
  37603. */
  37604. isPaused: boolean;
  37605. /**
  37606. * Does this sound enables spatial sound.
  37607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37608. */
  37609. spatialSound: boolean;
  37610. /**
  37611. * Define the reference distance the sound should be heard perfectly.
  37612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37613. */
  37614. refDistance: number;
  37615. /**
  37616. * Define the roll off factor of spatial sounds.
  37617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37618. */
  37619. rolloffFactor: number;
  37620. /**
  37621. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37623. */
  37624. maxDistance: number;
  37625. /**
  37626. * Define the distance attenuation model the sound will follow.
  37627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37628. */
  37629. distanceModel: string;
  37630. /**
  37631. * @hidden
  37632. * Back Compat
  37633. **/
  37634. onended: () => any;
  37635. /**
  37636. * Observable event when the current playing sound finishes.
  37637. */
  37638. onEndedObservable: Observable<Sound>;
  37639. private _panningModel;
  37640. private _playbackRate;
  37641. private _streaming;
  37642. private _startTime;
  37643. private _startOffset;
  37644. private _position;
  37645. /** @hidden */
  37646. _positionInEmitterSpace: boolean;
  37647. private _localDirection;
  37648. private _volume;
  37649. private _isReadyToPlay;
  37650. private _isDirectional;
  37651. private _readyToPlayCallback;
  37652. private _audioBuffer;
  37653. private _soundSource;
  37654. private _streamingSource;
  37655. private _soundPanner;
  37656. private _soundGain;
  37657. private _inputAudioNode;
  37658. private _outputAudioNode;
  37659. private _coneInnerAngle;
  37660. private _coneOuterAngle;
  37661. private _coneOuterGain;
  37662. private _scene;
  37663. private _connectedTransformNode;
  37664. private _customAttenuationFunction;
  37665. private _registerFunc;
  37666. private _isOutputConnected;
  37667. private _htmlAudioElement;
  37668. private _urlType;
  37669. private _length?;
  37670. private _offset?;
  37671. /** @hidden */
  37672. static _SceneComponentInitialization: (scene: Scene) => void;
  37673. /**
  37674. * Create a sound and attach it to a scene
  37675. * @param name Name of your sound
  37676. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37677. * @param scene defines the scene the sound belongs to
  37678. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37679. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37680. */
  37681. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37682. /**
  37683. * Release the sound and its associated resources
  37684. */
  37685. dispose(): void;
  37686. /**
  37687. * Gets if the sounds is ready to be played or not.
  37688. * @returns true if ready, otherwise false
  37689. */
  37690. isReady(): boolean;
  37691. private _soundLoaded;
  37692. /**
  37693. * Sets the data of the sound from an audiobuffer
  37694. * @param audioBuffer The audioBuffer containing the data
  37695. */
  37696. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37697. /**
  37698. * Updates the current sounds options such as maxdistance, loop...
  37699. * @param options A JSON object containing values named as the object properties
  37700. */
  37701. updateOptions(options: ISoundOptions): void;
  37702. private _createSpatialParameters;
  37703. private _updateSpatialParameters;
  37704. /**
  37705. * Switch the panning model to HRTF:
  37706. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37708. */
  37709. switchPanningModelToHRTF(): void;
  37710. /**
  37711. * Switch the panning model to Equal Power:
  37712. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37714. */
  37715. switchPanningModelToEqualPower(): void;
  37716. private _switchPanningModel;
  37717. /**
  37718. * Connect this sound to a sound track audio node like gain...
  37719. * @param soundTrackAudioNode the sound track audio node to connect to
  37720. */
  37721. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37722. /**
  37723. * Transform this sound into a directional source
  37724. * @param coneInnerAngle Size of the inner cone in degree
  37725. * @param coneOuterAngle Size of the outer cone in degree
  37726. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37727. */
  37728. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37729. /**
  37730. * Gets or sets the inner angle for the directional cone.
  37731. */
  37732. get directionalConeInnerAngle(): number;
  37733. /**
  37734. * Gets or sets the inner angle for the directional cone.
  37735. */
  37736. set directionalConeInnerAngle(value: number);
  37737. /**
  37738. * Gets or sets the outer angle for the directional cone.
  37739. */
  37740. get directionalConeOuterAngle(): number;
  37741. /**
  37742. * Gets or sets the outer angle for the directional cone.
  37743. */
  37744. set directionalConeOuterAngle(value: number);
  37745. /**
  37746. * Sets the position of the emitter if spatial sound is enabled
  37747. * @param newPosition Defines the new posisiton
  37748. */
  37749. setPosition(newPosition: Vector3): void;
  37750. /**
  37751. * Sets the local direction of the emitter if spatial sound is enabled
  37752. * @param newLocalDirection Defines the new local direction
  37753. */
  37754. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37755. private _updateDirection;
  37756. /** @hidden */
  37757. updateDistanceFromListener(): void;
  37758. /**
  37759. * Sets a new custom attenuation function for the sound.
  37760. * @param callback Defines the function used for the attenuation
  37761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37762. */
  37763. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37764. /**
  37765. * Play the sound
  37766. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37767. * @param offset (optional) Start the sound at a specific time in seconds
  37768. * @param length (optional) Sound duration (in seconds)
  37769. */
  37770. play(time?: number, offset?: number, length?: number): void;
  37771. private _onended;
  37772. /**
  37773. * Stop the sound
  37774. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37775. */
  37776. stop(time?: number): void;
  37777. /**
  37778. * Put the sound in pause
  37779. */
  37780. pause(): void;
  37781. /**
  37782. * Sets a dedicated volume for this sounds
  37783. * @param newVolume Define the new volume of the sound
  37784. * @param time Define time for gradual change to new volume
  37785. */
  37786. setVolume(newVolume: number, time?: number): void;
  37787. /**
  37788. * Set the sound play back rate
  37789. * @param newPlaybackRate Define the playback rate the sound should be played at
  37790. */
  37791. setPlaybackRate(newPlaybackRate: number): void;
  37792. /**
  37793. * Gets the volume of the sound.
  37794. * @returns the volume of the sound
  37795. */
  37796. getVolume(): number;
  37797. /**
  37798. * Attach the sound to a dedicated mesh
  37799. * @param transformNode The transform node to connect the sound with
  37800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37801. */
  37802. attachToMesh(transformNode: TransformNode): void;
  37803. /**
  37804. * Detach the sound from the previously attached mesh
  37805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37806. */
  37807. detachFromMesh(): void;
  37808. private _onRegisterAfterWorldMatrixUpdate;
  37809. /**
  37810. * Clone the current sound in the scene.
  37811. * @returns the new sound clone
  37812. */
  37813. clone(): Nullable<Sound>;
  37814. /**
  37815. * Gets the current underlying audio buffer containing the data
  37816. * @returns the audio buffer
  37817. */
  37818. getAudioBuffer(): Nullable<AudioBuffer>;
  37819. /**
  37820. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37821. * @returns the source node
  37822. */
  37823. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37824. /**
  37825. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37826. * @returns the gain node
  37827. */
  37828. getSoundGain(): Nullable<GainNode>;
  37829. /**
  37830. * Serializes the Sound in a JSON representation
  37831. * @returns the JSON representation of the sound
  37832. */
  37833. serialize(): any;
  37834. /**
  37835. * Parse a JSON representation of a sound to innstantiate in a given scene
  37836. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37837. * @param scene Define the scene the new parsed sound should be created in
  37838. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37839. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37840. * @returns the newly parsed sound
  37841. */
  37842. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37843. }
  37844. }
  37845. declare module BABYLON {
  37846. /**
  37847. * This defines an action helpful to play a defined sound on a triggered action.
  37848. */
  37849. export class PlaySoundAction extends Action {
  37850. private _sound;
  37851. /**
  37852. * Instantiate the action
  37853. * @param triggerOptions defines the trigger options
  37854. * @param sound defines the sound to play
  37855. * @param condition defines the trigger related conditions
  37856. */
  37857. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37858. /** @hidden */
  37859. _prepare(): void;
  37860. /**
  37861. * Execute the action and play the sound.
  37862. */
  37863. execute(): void;
  37864. /**
  37865. * Serializes the actions and its related information.
  37866. * @param parent defines the object to serialize in
  37867. * @returns the serialized object
  37868. */
  37869. serialize(parent: any): any;
  37870. }
  37871. /**
  37872. * This defines an action helpful to stop a defined sound on a triggered action.
  37873. */
  37874. export class StopSoundAction extends Action {
  37875. private _sound;
  37876. /**
  37877. * Instantiate the action
  37878. * @param triggerOptions defines the trigger options
  37879. * @param sound defines the sound to stop
  37880. * @param condition defines the trigger related conditions
  37881. */
  37882. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37883. /** @hidden */
  37884. _prepare(): void;
  37885. /**
  37886. * Execute the action and stop the sound.
  37887. */
  37888. execute(): void;
  37889. /**
  37890. * Serializes the actions and its related information.
  37891. * @param parent defines the object to serialize in
  37892. * @returns the serialized object
  37893. */
  37894. serialize(parent: any): any;
  37895. }
  37896. }
  37897. declare module BABYLON {
  37898. /**
  37899. * This defines an action responsible to change the value of a property
  37900. * by interpolating between its current value and the newly set one once triggered.
  37901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37902. */
  37903. export class InterpolateValueAction extends Action {
  37904. /**
  37905. * Defines the path of the property where the value should be interpolated
  37906. */
  37907. propertyPath: string;
  37908. /**
  37909. * Defines the target value at the end of the interpolation.
  37910. */
  37911. value: any;
  37912. /**
  37913. * Defines the time it will take for the property to interpolate to the value.
  37914. */
  37915. duration: number;
  37916. /**
  37917. * Defines if the other scene animations should be stopped when the action has been triggered
  37918. */
  37919. stopOtherAnimations?: boolean;
  37920. /**
  37921. * Defines a callback raised once the interpolation animation has been done.
  37922. */
  37923. onInterpolationDone?: () => void;
  37924. /**
  37925. * Observable triggered once the interpolation animation has been done.
  37926. */
  37927. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37928. private _target;
  37929. private _effectiveTarget;
  37930. private _property;
  37931. /**
  37932. * Instantiate the action
  37933. * @param triggerOptions defines the trigger options
  37934. * @param target defines the object containing the value to interpolate
  37935. * @param propertyPath defines the path to the property in the target object
  37936. * @param value defines the target value at the end of the interpolation
  37937. * @param duration deines the time it will take for the property to interpolate to the value.
  37938. * @param condition defines the trigger related conditions
  37939. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37940. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37941. */
  37942. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37943. /** @hidden */
  37944. _prepare(): void;
  37945. /**
  37946. * Execute the action starts the value interpolation.
  37947. */
  37948. execute(): void;
  37949. /**
  37950. * Serializes the actions and its related information.
  37951. * @param parent defines the object to serialize in
  37952. * @returns the serialized object
  37953. */
  37954. serialize(parent: any): any;
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. /**
  37959. * Options allowed during the creation of a sound track.
  37960. */
  37961. export interface ISoundTrackOptions {
  37962. /**
  37963. * The volume the sound track should take during creation
  37964. */
  37965. volume?: number;
  37966. /**
  37967. * Define if the sound track is the main sound track of the scene
  37968. */
  37969. mainTrack?: boolean;
  37970. }
  37971. /**
  37972. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37973. * It will be also used in a future release to apply effects on a specific track.
  37974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37975. */
  37976. export class SoundTrack {
  37977. /**
  37978. * The unique identifier of the sound track in the scene.
  37979. */
  37980. id: number;
  37981. /**
  37982. * The list of sounds included in the sound track.
  37983. */
  37984. soundCollection: Array<Sound>;
  37985. private _outputAudioNode;
  37986. private _scene;
  37987. private _connectedAnalyser;
  37988. private _options;
  37989. private _isInitialized;
  37990. /**
  37991. * Creates a new sound track.
  37992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37993. * @param scene Define the scene the sound track belongs to
  37994. * @param options
  37995. */
  37996. constructor(scene: Scene, options?: ISoundTrackOptions);
  37997. private _initializeSoundTrackAudioGraph;
  37998. /**
  37999. * Release the sound track and its associated resources
  38000. */
  38001. dispose(): void;
  38002. /**
  38003. * Adds a sound to this sound track
  38004. * @param sound define the cound to add
  38005. * @ignoreNaming
  38006. */
  38007. AddSound(sound: Sound): void;
  38008. /**
  38009. * Removes a sound to this sound track
  38010. * @param sound define the cound to remove
  38011. * @ignoreNaming
  38012. */
  38013. RemoveSound(sound: Sound): void;
  38014. /**
  38015. * Set a global volume for the full sound track.
  38016. * @param newVolume Define the new volume of the sound track
  38017. */
  38018. setVolume(newVolume: number): void;
  38019. /**
  38020. * Switch the panning model to HRTF:
  38021. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38023. */
  38024. switchPanningModelToHRTF(): void;
  38025. /**
  38026. * Switch the panning model to Equal Power:
  38027. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38029. */
  38030. switchPanningModelToEqualPower(): void;
  38031. /**
  38032. * Connect the sound track to an audio analyser allowing some amazing
  38033. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38035. * @param analyser The analyser to connect to the engine
  38036. */
  38037. connectToAnalyser(analyser: Analyser): void;
  38038. }
  38039. }
  38040. declare module BABYLON {
  38041. interface AbstractScene {
  38042. /**
  38043. * The list of sounds used in the scene.
  38044. */
  38045. sounds: Nullable<Array<Sound>>;
  38046. }
  38047. interface Scene {
  38048. /**
  38049. * @hidden
  38050. * Backing field
  38051. */
  38052. _mainSoundTrack: SoundTrack;
  38053. /**
  38054. * The main sound track played by the scene.
  38055. * It cotains your primary collection of sounds.
  38056. */
  38057. mainSoundTrack: SoundTrack;
  38058. /**
  38059. * The list of sound tracks added to the scene
  38060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38061. */
  38062. soundTracks: Nullable<Array<SoundTrack>>;
  38063. /**
  38064. * Gets a sound using a given name
  38065. * @param name defines the name to search for
  38066. * @return the found sound or null if not found at all.
  38067. */
  38068. getSoundByName(name: string): Nullable<Sound>;
  38069. /**
  38070. * Gets or sets if audio support is enabled
  38071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38072. */
  38073. audioEnabled: boolean;
  38074. /**
  38075. * Gets or sets if audio will be output to headphones
  38076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38077. */
  38078. headphone: boolean;
  38079. /**
  38080. * Gets or sets custom audio listener position provider
  38081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38082. */
  38083. audioListenerPositionProvider: Nullable<() => Vector3>;
  38084. /**
  38085. * Gets or sets a refresh rate when using 3D audio positioning
  38086. */
  38087. audioPositioningRefreshRate: number;
  38088. }
  38089. /**
  38090. * Defines the sound scene component responsible to manage any sounds
  38091. * in a given scene.
  38092. */
  38093. export class AudioSceneComponent implements ISceneSerializableComponent {
  38094. /**
  38095. * The component name helpfull to identify the component in the list of scene components.
  38096. */
  38097. readonly name: string;
  38098. /**
  38099. * The scene the component belongs to.
  38100. */
  38101. scene: Scene;
  38102. private _audioEnabled;
  38103. /**
  38104. * Gets whether audio is enabled or not.
  38105. * Please use related enable/disable method to switch state.
  38106. */
  38107. get audioEnabled(): boolean;
  38108. private _headphone;
  38109. /**
  38110. * Gets whether audio is outputing to headphone or not.
  38111. * Please use the according Switch methods to change output.
  38112. */
  38113. get headphone(): boolean;
  38114. /**
  38115. * Gets or sets a refresh rate when using 3D audio positioning
  38116. */
  38117. audioPositioningRefreshRate: number;
  38118. private _audioListenerPositionProvider;
  38119. /**
  38120. * Gets the current audio listener position provider
  38121. */
  38122. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38123. /**
  38124. * Sets a custom listener position for all sounds in the scene
  38125. * By default, this is the position of the first active camera
  38126. */
  38127. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38128. /**
  38129. * Creates a new instance of the component for the given scene
  38130. * @param scene Defines the scene to register the component in
  38131. */
  38132. constructor(scene: Scene);
  38133. /**
  38134. * Registers the component in a given scene
  38135. */
  38136. register(): void;
  38137. /**
  38138. * Rebuilds the elements related to this component in case of
  38139. * context lost for instance.
  38140. */
  38141. rebuild(): void;
  38142. /**
  38143. * Serializes the component data to the specified json object
  38144. * @param serializationObject The object to serialize to
  38145. */
  38146. serialize(serializationObject: any): void;
  38147. /**
  38148. * Adds all the elements from the container to the scene
  38149. * @param container the container holding the elements
  38150. */
  38151. addFromContainer(container: AbstractScene): void;
  38152. /**
  38153. * Removes all the elements in the container from the scene
  38154. * @param container contains the elements to remove
  38155. * @param dispose if the removed element should be disposed (default: false)
  38156. */
  38157. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38158. /**
  38159. * Disposes the component and the associated ressources.
  38160. */
  38161. dispose(): void;
  38162. /**
  38163. * Disables audio in the associated scene.
  38164. */
  38165. disableAudio(): void;
  38166. /**
  38167. * Enables audio in the associated scene.
  38168. */
  38169. enableAudio(): void;
  38170. /**
  38171. * Switch audio to headphone output.
  38172. */
  38173. switchAudioModeForHeadphones(): void;
  38174. /**
  38175. * Switch audio to normal speakers.
  38176. */
  38177. switchAudioModeForNormalSpeakers(): void;
  38178. private _cachedCameraDirection;
  38179. private _cachedCameraPosition;
  38180. private _lastCheck;
  38181. private _afterRender;
  38182. }
  38183. }
  38184. declare module BABYLON {
  38185. /**
  38186. * Wraps one or more Sound objects and selects one with random weight for playback.
  38187. */
  38188. export class WeightedSound {
  38189. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38190. loop: boolean;
  38191. private _coneInnerAngle;
  38192. private _coneOuterAngle;
  38193. private _volume;
  38194. /** A Sound is currently playing. */
  38195. isPlaying: boolean;
  38196. /** A Sound is currently paused. */
  38197. isPaused: boolean;
  38198. private _sounds;
  38199. private _weights;
  38200. private _currentIndex?;
  38201. /**
  38202. * Creates a new WeightedSound from the list of sounds given.
  38203. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38204. * @param sounds Array of Sounds that will be selected from.
  38205. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38206. */
  38207. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38208. /**
  38209. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38210. */
  38211. get directionalConeInnerAngle(): number;
  38212. /**
  38213. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38214. */
  38215. set directionalConeInnerAngle(value: number);
  38216. /**
  38217. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38218. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38219. */
  38220. get directionalConeOuterAngle(): number;
  38221. /**
  38222. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38223. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38224. */
  38225. set directionalConeOuterAngle(value: number);
  38226. /**
  38227. * Playback volume.
  38228. */
  38229. get volume(): number;
  38230. /**
  38231. * Playback volume.
  38232. */
  38233. set volume(value: number);
  38234. private _onended;
  38235. /**
  38236. * Suspend playback
  38237. */
  38238. pause(): void;
  38239. /**
  38240. * Stop playback
  38241. */
  38242. stop(): void;
  38243. /**
  38244. * Start playback.
  38245. * @param startOffset Position the clip head at a specific time in seconds.
  38246. */
  38247. play(startOffset?: number): void;
  38248. }
  38249. }
  38250. declare module BABYLON {
  38251. /**
  38252. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38253. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38254. */
  38255. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38256. /**
  38257. * Gets the name of the behavior.
  38258. */
  38259. get name(): string;
  38260. /**
  38261. * The easing function used by animations
  38262. */
  38263. static EasingFunction: BackEase;
  38264. /**
  38265. * The easing mode used by animations
  38266. */
  38267. static EasingMode: number;
  38268. /**
  38269. * The duration of the animation, in milliseconds
  38270. */
  38271. transitionDuration: number;
  38272. /**
  38273. * Length of the distance animated by the transition when lower radius is reached
  38274. */
  38275. lowerRadiusTransitionRange: number;
  38276. /**
  38277. * Length of the distance animated by the transition when upper radius is reached
  38278. */
  38279. upperRadiusTransitionRange: number;
  38280. private _autoTransitionRange;
  38281. /**
  38282. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38283. */
  38284. get autoTransitionRange(): boolean;
  38285. /**
  38286. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38287. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38288. */
  38289. set autoTransitionRange(value: boolean);
  38290. private _attachedCamera;
  38291. private _onAfterCheckInputsObserver;
  38292. private _onMeshTargetChangedObserver;
  38293. /**
  38294. * Initializes the behavior.
  38295. */
  38296. init(): void;
  38297. /**
  38298. * Attaches the behavior to its arc rotate camera.
  38299. * @param camera Defines the camera to attach the behavior to
  38300. */
  38301. attach(camera: ArcRotateCamera): void;
  38302. /**
  38303. * Detaches the behavior from its current arc rotate camera.
  38304. */
  38305. detach(): void;
  38306. private _radiusIsAnimating;
  38307. private _radiusBounceTransition;
  38308. private _animatables;
  38309. private _cachedWheelPrecision;
  38310. /**
  38311. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38312. * @param radiusLimit The limit to check against.
  38313. * @return Bool to indicate if at limit.
  38314. */
  38315. private _isRadiusAtLimit;
  38316. /**
  38317. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38318. * @param radiusDelta The delta by which to animate to. Can be negative.
  38319. */
  38320. private _applyBoundRadiusAnimation;
  38321. /**
  38322. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38323. */
  38324. protected _clearAnimationLocks(): void;
  38325. /**
  38326. * Stops and removes all animations that have been applied to the camera
  38327. */
  38328. stopAllAnimations(): void;
  38329. }
  38330. }
  38331. declare module BABYLON {
  38332. /**
  38333. * 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.
  38334. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38335. */
  38336. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38337. /**
  38338. * Gets the name of the behavior.
  38339. */
  38340. get name(): string;
  38341. private _mode;
  38342. private _radiusScale;
  38343. private _positionScale;
  38344. private _defaultElevation;
  38345. private _elevationReturnTime;
  38346. private _elevationReturnWaitTime;
  38347. private _zoomStopsAnimation;
  38348. private _framingTime;
  38349. /**
  38350. * The easing function used by animations
  38351. */
  38352. static EasingFunction: ExponentialEase;
  38353. /**
  38354. * The easing mode used by animations
  38355. */
  38356. static EasingMode: number;
  38357. /**
  38358. * Sets the current mode used by the behavior
  38359. */
  38360. set mode(mode: number);
  38361. /**
  38362. * Gets current mode used by the behavior.
  38363. */
  38364. get mode(): number;
  38365. /**
  38366. * Sets the scale applied to the radius (1 by default)
  38367. */
  38368. set radiusScale(radius: number);
  38369. /**
  38370. * Gets the scale applied to the radius
  38371. */
  38372. get radiusScale(): number;
  38373. /**
  38374. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38375. */
  38376. set positionScale(scale: number);
  38377. /**
  38378. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38379. */
  38380. get positionScale(): number;
  38381. /**
  38382. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38383. * behaviour is triggered, in radians.
  38384. */
  38385. set defaultElevation(elevation: number);
  38386. /**
  38387. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38388. * behaviour is triggered, in radians.
  38389. */
  38390. get defaultElevation(): number;
  38391. /**
  38392. * Sets the time (in milliseconds) taken to return to the default beta position.
  38393. * Negative value indicates camera should not return to default.
  38394. */
  38395. set elevationReturnTime(speed: number);
  38396. /**
  38397. * Gets the time (in milliseconds) taken to return to the default beta position.
  38398. * Negative value indicates camera should not return to default.
  38399. */
  38400. get elevationReturnTime(): number;
  38401. /**
  38402. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38403. */
  38404. set elevationReturnWaitTime(time: number);
  38405. /**
  38406. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38407. */
  38408. get elevationReturnWaitTime(): number;
  38409. /**
  38410. * Sets the flag that indicates if user zooming should stop animation.
  38411. */
  38412. set zoomStopsAnimation(flag: boolean);
  38413. /**
  38414. * Gets the flag that indicates if user zooming should stop animation.
  38415. */
  38416. get zoomStopsAnimation(): boolean;
  38417. /**
  38418. * Sets the transition time when framing the mesh, in milliseconds
  38419. */
  38420. set framingTime(time: number);
  38421. /**
  38422. * Gets the transition time when framing the mesh, in milliseconds
  38423. */
  38424. get framingTime(): number;
  38425. /**
  38426. * Define if the behavior should automatically change the configured
  38427. * camera limits and sensibilities.
  38428. */
  38429. autoCorrectCameraLimitsAndSensibility: boolean;
  38430. private _onPrePointerObservableObserver;
  38431. private _onAfterCheckInputsObserver;
  38432. private _onMeshTargetChangedObserver;
  38433. private _attachedCamera;
  38434. private _isPointerDown;
  38435. private _lastInteractionTime;
  38436. /**
  38437. * Initializes the behavior.
  38438. */
  38439. init(): void;
  38440. /**
  38441. * Attaches the behavior to its arc rotate camera.
  38442. * @param camera Defines the camera to attach the behavior to
  38443. */
  38444. attach(camera: ArcRotateCamera): void;
  38445. /**
  38446. * Detaches the behavior from its current arc rotate camera.
  38447. */
  38448. detach(): void;
  38449. private _animatables;
  38450. private _betaIsAnimating;
  38451. private _betaTransition;
  38452. private _radiusTransition;
  38453. private _vectorTransition;
  38454. /**
  38455. * Targets the given mesh and updates zoom level accordingly.
  38456. * @param mesh The mesh to target.
  38457. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38458. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38459. */
  38460. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38461. /**
  38462. * Targets the given mesh with its children and updates zoom level accordingly.
  38463. * @param mesh The mesh to target.
  38464. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38465. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38466. */
  38467. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38468. /**
  38469. * Targets the given meshes with their children and updates zoom level accordingly.
  38470. * @param meshes The mesh to target.
  38471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38473. */
  38474. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38475. /**
  38476. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38477. * @param minimumWorld Determines the smaller position of the bounding box extend
  38478. * @param maximumWorld Determines the bigger position of the bounding box extend
  38479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38481. */
  38482. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38483. /**
  38484. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38485. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38486. * frustum width.
  38487. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38488. * to fully enclose the mesh in the viewing frustum.
  38489. */
  38490. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38491. /**
  38492. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38493. * is automatically returned to its default position (expected to be above ground plane).
  38494. */
  38495. private _maintainCameraAboveGround;
  38496. /**
  38497. * Returns the frustum slope based on the canvas ratio and camera FOV
  38498. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38499. */
  38500. private _getFrustumSlope;
  38501. /**
  38502. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38503. */
  38504. private _clearAnimationLocks;
  38505. /**
  38506. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38507. */
  38508. private _applyUserInteraction;
  38509. /**
  38510. * Stops and removes all animations that have been applied to the camera
  38511. */
  38512. stopAllAnimations(): void;
  38513. /**
  38514. * Gets a value indicating if the user is moving the camera
  38515. */
  38516. get isUserIsMoving(): boolean;
  38517. /**
  38518. * The camera can move all the way towards the mesh.
  38519. */
  38520. static IgnoreBoundsSizeMode: number;
  38521. /**
  38522. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38523. */
  38524. static FitFrustumSidesMode: number;
  38525. }
  38526. }
  38527. declare module BABYLON {
  38528. /**
  38529. * Base class for Camera Pointer Inputs.
  38530. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38531. * for example usage.
  38532. */
  38533. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38534. /**
  38535. * Defines the camera the input is attached to.
  38536. */
  38537. abstract camera: Camera;
  38538. /**
  38539. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38540. */
  38541. protected _altKey: boolean;
  38542. protected _ctrlKey: boolean;
  38543. protected _metaKey: boolean;
  38544. protected _shiftKey: boolean;
  38545. /**
  38546. * Which mouse buttons were pressed at time of last mouse event.
  38547. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38548. */
  38549. protected _buttonsPressed: number;
  38550. /**
  38551. * Defines the buttons associated with the input to handle camera move.
  38552. */
  38553. buttons: number[];
  38554. /**
  38555. * Attach the input controls to a specific dom element to get the input from.
  38556. * @param element Defines the element the controls should be listened from
  38557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38558. */
  38559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38560. /**
  38561. * Detach the current controls from the specified dom element.
  38562. * @param element Defines the element to stop listening the inputs from
  38563. */
  38564. detachControl(element: Nullable<HTMLElement>): void;
  38565. /**
  38566. * Gets the class name of the current input.
  38567. * @returns the class name
  38568. */
  38569. getClassName(): string;
  38570. /**
  38571. * Get the friendly name associated with the input class.
  38572. * @returns the input friendly name
  38573. */
  38574. getSimpleName(): string;
  38575. /**
  38576. * Called on pointer POINTERDOUBLETAP event.
  38577. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38578. */
  38579. protected onDoubleTap(type: string): void;
  38580. /**
  38581. * Called on pointer POINTERMOVE event if only a single touch is active.
  38582. * Override this method to provide functionality.
  38583. */
  38584. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38585. /**
  38586. * Called on pointer POINTERMOVE event if multiple touches are active.
  38587. * Override this method to provide functionality.
  38588. */
  38589. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38590. /**
  38591. * Called on JS contextmenu event.
  38592. * Override this method to provide functionality.
  38593. */
  38594. protected onContextMenu(evt: PointerEvent): void;
  38595. /**
  38596. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38597. * press.
  38598. * Override this method to provide functionality.
  38599. */
  38600. protected onButtonDown(evt: PointerEvent): void;
  38601. /**
  38602. * Called each time a new POINTERUP event occurs. Ie, for each button
  38603. * release.
  38604. * Override this method to provide functionality.
  38605. */
  38606. protected onButtonUp(evt: PointerEvent): void;
  38607. /**
  38608. * Called when window becomes inactive.
  38609. * Override this method to provide functionality.
  38610. */
  38611. protected onLostFocus(): void;
  38612. private _pointerInput;
  38613. private _observer;
  38614. private _onLostFocus;
  38615. private pointA;
  38616. private pointB;
  38617. }
  38618. }
  38619. declare module BABYLON {
  38620. /**
  38621. * Manage the pointers inputs to control an arc rotate camera.
  38622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38623. */
  38624. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38625. /**
  38626. * Defines the camera the input is attached to.
  38627. */
  38628. camera: ArcRotateCamera;
  38629. /**
  38630. * Gets the class name of the current input.
  38631. * @returns the class name
  38632. */
  38633. getClassName(): string;
  38634. /**
  38635. * Defines the buttons associated with the input to handle camera move.
  38636. */
  38637. buttons: number[];
  38638. /**
  38639. * Defines the pointer angular sensibility along the X axis or how fast is
  38640. * the camera rotating.
  38641. */
  38642. angularSensibilityX: number;
  38643. /**
  38644. * Defines the pointer angular sensibility along the Y axis or how fast is
  38645. * the camera rotating.
  38646. */
  38647. angularSensibilityY: number;
  38648. /**
  38649. * Defines the pointer pinch precision or how fast is the camera zooming.
  38650. */
  38651. pinchPrecision: number;
  38652. /**
  38653. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38654. * from 0.
  38655. * It defines the percentage of current camera.radius to use as delta when
  38656. * pinch zoom is used.
  38657. */
  38658. pinchDeltaPercentage: number;
  38659. /**
  38660. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38661. * that any object in the plane at the camera's target point will scale
  38662. * perfectly with finger motion.
  38663. * Overrides pinchDeltaPercentage and pinchPrecision.
  38664. */
  38665. useNaturalPinchZoom: boolean;
  38666. /**
  38667. * Defines the pointer panning sensibility or how fast is the camera moving.
  38668. */
  38669. panningSensibility: number;
  38670. /**
  38671. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38672. */
  38673. multiTouchPanning: boolean;
  38674. /**
  38675. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38676. * zoom (pinch) through multitouch.
  38677. */
  38678. multiTouchPanAndZoom: boolean;
  38679. /**
  38680. * Revers pinch action direction.
  38681. */
  38682. pinchInwards: boolean;
  38683. private _isPanClick;
  38684. private _twoFingerActivityCount;
  38685. private _isPinching;
  38686. /**
  38687. * Called on pointer POINTERMOVE event if only a single touch is active.
  38688. */
  38689. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38690. /**
  38691. * Called on pointer POINTERDOUBLETAP event.
  38692. */
  38693. protected onDoubleTap(type: string): void;
  38694. /**
  38695. * Called on pointer POINTERMOVE event if multiple touches are active.
  38696. */
  38697. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38698. /**
  38699. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38700. * press.
  38701. */
  38702. protected onButtonDown(evt: PointerEvent): void;
  38703. /**
  38704. * Called each time a new POINTERUP event occurs. Ie, for each button
  38705. * release.
  38706. */
  38707. protected onButtonUp(evt: PointerEvent): void;
  38708. /**
  38709. * Called when window becomes inactive.
  38710. */
  38711. protected onLostFocus(): void;
  38712. }
  38713. }
  38714. declare module BABYLON {
  38715. /**
  38716. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38718. */
  38719. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38720. /**
  38721. * Defines the camera the input is attached to.
  38722. */
  38723. camera: ArcRotateCamera;
  38724. /**
  38725. * Defines the list of key codes associated with the up action (increase alpha)
  38726. */
  38727. keysUp: number[];
  38728. /**
  38729. * Defines the list of key codes associated with the down action (decrease alpha)
  38730. */
  38731. keysDown: number[];
  38732. /**
  38733. * Defines the list of key codes associated with the left action (increase beta)
  38734. */
  38735. keysLeft: number[];
  38736. /**
  38737. * Defines the list of key codes associated with the right action (decrease beta)
  38738. */
  38739. keysRight: number[];
  38740. /**
  38741. * Defines the list of key codes associated with the reset action.
  38742. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38743. */
  38744. keysReset: number[];
  38745. /**
  38746. * Defines the panning sensibility of the inputs.
  38747. * (How fast is the camera panning)
  38748. */
  38749. panningSensibility: number;
  38750. /**
  38751. * Defines the zooming sensibility of the inputs.
  38752. * (How fast is the camera zooming)
  38753. */
  38754. zoomingSensibility: number;
  38755. /**
  38756. * Defines whether maintaining the alt key down switch the movement mode from
  38757. * orientation to zoom.
  38758. */
  38759. useAltToZoom: boolean;
  38760. /**
  38761. * Rotation speed of the camera
  38762. */
  38763. angularSpeed: number;
  38764. private _keys;
  38765. private _ctrlPressed;
  38766. private _altPressed;
  38767. private _onCanvasBlurObserver;
  38768. private _onKeyboardObserver;
  38769. private _engine;
  38770. private _scene;
  38771. /**
  38772. * Attach the input controls to a specific dom element to get the input from.
  38773. * @param element Defines the element the controls should be listened from
  38774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38775. */
  38776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38777. /**
  38778. * Detach the current controls from the specified dom element.
  38779. * @param element Defines the element to stop listening the inputs from
  38780. */
  38781. detachControl(element: Nullable<HTMLElement>): void;
  38782. /**
  38783. * Update the current camera state depending on the inputs that have been used this frame.
  38784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38785. */
  38786. checkInputs(): void;
  38787. /**
  38788. * Gets the class name of the current intput.
  38789. * @returns the class name
  38790. */
  38791. getClassName(): string;
  38792. /**
  38793. * Get the friendly name associated with the input class.
  38794. * @returns the input friendly name
  38795. */
  38796. getSimpleName(): string;
  38797. }
  38798. }
  38799. declare module BABYLON {
  38800. /**
  38801. * Manage the mouse wheel inputs to control an arc rotate camera.
  38802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38803. */
  38804. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38805. /**
  38806. * Defines the camera the input is attached to.
  38807. */
  38808. camera: ArcRotateCamera;
  38809. /**
  38810. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38811. */
  38812. wheelPrecision: number;
  38813. /**
  38814. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38815. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38816. */
  38817. wheelDeltaPercentage: number;
  38818. private _wheel;
  38819. private _observer;
  38820. private computeDeltaFromMouseWheelLegacyEvent;
  38821. /**
  38822. * Attach the input controls to a specific dom element to get the input from.
  38823. * @param element Defines the element the controls should be listened from
  38824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38825. */
  38826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38827. /**
  38828. * Detach the current controls from the specified dom element.
  38829. * @param element Defines the element to stop listening the inputs from
  38830. */
  38831. detachControl(element: Nullable<HTMLElement>): void;
  38832. /**
  38833. * Gets the class name of the current intput.
  38834. * @returns the class name
  38835. */
  38836. getClassName(): string;
  38837. /**
  38838. * Get the friendly name associated with the input class.
  38839. * @returns the input friendly name
  38840. */
  38841. getSimpleName(): string;
  38842. }
  38843. }
  38844. declare module BABYLON {
  38845. /**
  38846. * Default Inputs manager for the ArcRotateCamera.
  38847. * It groups all the default supported inputs for ease of use.
  38848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38849. */
  38850. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38851. /**
  38852. * Instantiates a new ArcRotateCameraInputsManager.
  38853. * @param camera Defines the camera the inputs belong to
  38854. */
  38855. constructor(camera: ArcRotateCamera);
  38856. /**
  38857. * Add mouse wheel input support to the input manager.
  38858. * @returns the current input manager
  38859. */
  38860. addMouseWheel(): ArcRotateCameraInputsManager;
  38861. /**
  38862. * Add pointers input support to the input manager.
  38863. * @returns the current input manager
  38864. */
  38865. addPointers(): ArcRotateCameraInputsManager;
  38866. /**
  38867. * Add keyboard input support to the input manager.
  38868. * @returns the current input manager
  38869. */
  38870. addKeyboard(): ArcRotateCameraInputsManager;
  38871. }
  38872. }
  38873. declare module BABYLON {
  38874. /**
  38875. * This represents an orbital type of camera.
  38876. *
  38877. * 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.
  38878. * 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.
  38879. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38880. */
  38881. export class ArcRotateCamera extends TargetCamera {
  38882. /**
  38883. * Defines the rotation angle of the camera along the longitudinal axis.
  38884. */
  38885. alpha: number;
  38886. /**
  38887. * Defines the rotation angle of the camera along the latitudinal axis.
  38888. */
  38889. beta: number;
  38890. /**
  38891. * Defines the radius of the camera from it s target point.
  38892. */
  38893. radius: number;
  38894. protected _target: Vector3;
  38895. protected _targetHost: Nullable<AbstractMesh>;
  38896. /**
  38897. * Defines the target point of the camera.
  38898. * The camera looks towards it form the radius distance.
  38899. */
  38900. get target(): Vector3;
  38901. set target(value: Vector3);
  38902. /**
  38903. * Define the current local position of the camera in the scene
  38904. */
  38905. get position(): Vector3;
  38906. set position(newPosition: Vector3);
  38907. protected _upVector: Vector3;
  38908. protected _upToYMatrix: Matrix;
  38909. protected _YToUpMatrix: Matrix;
  38910. /**
  38911. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38912. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38913. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38914. */
  38915. set upVector(vec: Vector3);
  38916. get upVector(): Vector3;
  38917. /**
  38918. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38919. */
  38920. setMatUp(): void;
  38921. /**
  38922. * Current inertia value on the longitudinal axis.
  38923. * The bigger this number the longer it will take for the camera to stop.
  38924. */
  38925. inertialAlphaOffset: number;
  38926. /**
  38927. * Current inertia value on the latitudinal axis.
  38928. * The bigger this number the longer it will take for the camera to stop.
  38929. */
  38930. inertialBetaOffset: number;
  38931. /**
  38932. * Current inertia value on the radius axis.
  38933. * The bigger this number the longer it will take for the camera to stop.
  38934. */
  38935. inertialRadiusOffset: number;
  38936. /**
  38937. * Minimum allowed angle on the longitudinal axis.
  38938. * This can help limiting how the Camera is able to move in the scene.
  38939. */
  38940. lowerAlphaLimit: Nullable<number>;
  38941. /**
  38942. * Maximum allowed angle on the longitudinal axis.
  38943. * This can help limiting how the Camera is able to move in the scene.
  38944. */
  38945. upperAlphaLimit: Nullable<number>;
  38946. /**
  38947. * Minimum allowed angle on the latitudinal axis.
  38948. * This can help limiting how the Camera is able to move in the scene.
  38949. */
  38950. lowerBetaLimit: number;
  38951. /**
  38952. * Maximum allowed angle on the latitudinal axis.
  38953. * This can help limiting how the Camera is able to move in the scene.
  38954. */
  38955. upperBetaLimit: number;
  38956. /**
  38957. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38958. * This can help limiting how the Camera is able to move in the scene.
  38959. */
  38960. lowerRadiusLimit: Nullable<number>;
  38961. /**
  38962. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38963. * This can help limiting how the Camera is able to move in the scene.
  38964. */
  38965. upperRadiusLimit: Nullable<number>;
  38966. /**
  38967. * Defines the current inertia value used during panning of the camera along the X axis.
  38968. */
  38969. inertialPanningX: number;
  38970. /**
  38971. * Defines the current inertia value used during panning of the camera along the Y axis.
  38972. */
  38973. inertialPanningY: number;
  38974. /**
  38975. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38976. * Basically if your fingers moves away from more than this distance you will be considered
  38977. * in pinch mode.
  38978. */
  38979. pinchToPanMaxDistance: number;
  38980. /**
  38981. * Defines the maximum distance the camera can pan.
  38982. * This could help keeping the cammera always in your scene.
  38983. */
  38984. panningDistanceLimit: Nullable<number>;
  38985. /**
  38986. * Defines the target of the camera before paning.
  38987. */
  38988. panningOriginTarget: Vector3;
  38989. /**
  38990. * Defines the value of the inertia used during panning.
  38991. * 0 would mean stop inertia and one would mean no decelleration at all.
  38992. */
  38993. panningInertia: number;
  38994. /**
  38995. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38996. */
  38997. get angularSensibilityX(): number;
  38998. set angularSensibilityX(value: number);
  38999. /**
  39000. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39001. */
  39002. get angularSensibilityY(): number;
  39003. set angularSensibilityY(value: number);
  39004. /**
  39005. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39006. */
  39007. get pinchPrecision(): number;
  39008. set pinchPrecision(value: number);
  39009. /**
  39010. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39011. * It will be used instead of pinchDeltaPrecision if different from 0.
  39012. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39013. */
  39014. get pinchDeltaPercentage(): number;
  39015. set pinchDeltaPercentage(value: number);
  39016. /**
  39017. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39018. * and pinch delta percentage.
  39019. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39020. * that any object in the plane at the camera's target point will scale
  39021. * perfectly with finger motion.
  39022. */
  39023. get useNaturalPinchZoom(): boolean;
  39024. set useNaturalPinchZoom(value: boolean);
  39025. /**
  39026. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39027. */
  39028. get panningSensibility(): number;
  39029. set panningSensibility(value: number);
  39030. /**
  39031. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39032. */
  39033. get keysUp(): number[];
  39034. set keysUp(value: number[]);
  39035. /**
  39036. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39037. */
  39038. get keysDown(): number[];
  39039. set keysDown(value: number[]);
  39040. /**
  39041. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39042. */
  39043. get keysLeft(): number[];
  39044. set keysLeft(value: number[]);
  39045. /**
  39046. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39047. */
  39048. get keysRight(): number[];
  39049. set keysRight(value: number[]);
  39050. /**
  39051. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39052. */
  39053. get wheelPrecision(): number;
  39054. set wheelPrecision(value: number);
  39055. /**
  39056. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39057. * It will be used instead of pinchDeltaPrecision if different from 0.
  39058. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39059. */
  39060. get wheelDeltaPercentage(): number;
  39061. set wheelDeltaPercentage(value: number);
  39062. /**
  39063. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39064. */
  39065. zoomOnFactor: number;
  39066. /**
  39067. * Defines a screen offset for the camera position.
  39068. */
  39069. targetScreenOffset: Vector2;
  39070. /**
  39071. * Allows the camera to be completely reversed.
  39072. * If false the camera can not arrive upside down.
  39073. */
  39074. allowUpsideDown: boolean;
  39075. /**
  39076. * Define if double tap/click is used to restore the previously saved state of the camera.
  39077. */
  39078. useInputToRestoreState: boolean;
  39079. /** @hidden */
  39080. _viewMatrix: Matrix;
  39081. /** @hidden */
  39082. _useCtrlForPanning: boolean;
  39083. /** @hidden */
  39084. _panningMouseButton: number;
  39085. /**
  39086. * Defines the input associated to the camera.
  39087. */
  39088. inputs: ArcRotateCameraInputsManager;
  39089. /** @hidden */
  39090. _reset: () => void;
  39091. /**
  39092. * Defines the allowed panning axis.
  39093. */
  39094. panningAxis: Vector3;
  39095. protected _localDirection: Vector3;
  39096. protected _transformedDirection: Vector3;
  39097. private _bouncingBehavior;
  39098. /**
  39099. * Gets the bouncing behavior of the camera if it has been enabled.
  39100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39101. */
  39102. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39103. /**
  39104. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39106. */
  39107. get useBouncingBehavior(): boolean;
  39108. set useBouncingBehavior(value: boolean);
  39109. private _framingBehavior;
  39110. /**
  39111. * Gets the framing behavior of the camera if it has been enabled.
  39112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39113. */
  39114. get framingBehavior(): Nullable<FramingBehavior>;
  39115. /**
  39116. * Defines if the framing behavior of the camera is enabled on the camera.
  39117. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39118. */
  39119. get useFramingBehavior(): boolean;
  39120. set useFramingBehavior(value: boolean);
  39121. private _autoRotationBehavior;
  39122. /**
  39123. * Gets the auto rotation behavior of the camera if it has been enabled.
  39124. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39125. */
  39126. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39127. /**
  39128. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39130. */
  39131. get useAutoRotationBehavior(): boolean;
  39132. set useAutoRotationBehavior(value: boolean);
  39133. /**
  39134. * Observable triggered when the mesh target has been changed on the camera.
  39135. */
  39136. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39137. /**
  39138. * Event raised when the camera is colliding with a mesh.
  39139. */
  39140. onCollide: (collidedMesh: AbstractMesh) => void;
  39141. /**
  39142. * Defines whether the camera should check collision with the objects oh the scene.
  39143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39144. */
  39145. checkCollisions: boolean;
  39146. /**
  39147. * Defines the collision radius of the camera.
  39148. * This simulates a sphere around the camera.
  39149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39150. */
  39151. collisionRadius: Vector3;
  39152. protected _collider: Collider;
  39153. protected _previousPosition: Vector3;
  39154. protected _collisionVelocity: Vector3;
  39155. protected _newPosition: Vector3;
  39156. protected _previousAlpha: number;
  39157. protected _previousBeta: number;
  39158. protected _previousRadius: number;
  39159. protected _collisionTriggered: boolean;
  39160. protected _targetBoundingCenter: Nullable<Vector3>;
  39161. private _computationVector;
  39162. /**
  39163. * Instantiates a new ArcRotateCamera in a given scene
  39164. * @param name Defines the name of the camera
  39165. * @param alpha Defines the camera rotation along the logitudinal axis
  39166. * @param beta Defines the camera rotation along the latitudinal axis
  39167. * @param radius Defines the camera distance from its target
  39168. * @param target Defines the camera target
  39169. * @param scene Defines the scene the camera belongs to
  39170. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39171. */
  39172. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39173. /** @hidden */
  39174. _initCache(): void;
  39175. /** @hidden */
  39176. _updateCache(ignoreParentClass?: boolean): void;
  39177. protected _getTargetPosition(): Vector3;
  39178. private _storedAlpha;
  39179. private _storedBeta;
  39180. private _storedRadius;
  39181. private _storedTarget;
  39182. private _storedTargetScreenOffset;
  39183. /**
  39184. * Stores the current state of the camera (alpha, beta, radius and target)
  39185. * @returns the camera itself
  39186. */
  39187. storeState(): Camera;
  39188. /**
  39189. * @hidden
  39190. * Restored camera state. You must call storeState() first
  39191. */
  39192. _restoreStateValues(): boolean;
  39193. /** @hidden */
  39194. _isSynchronizedViewMatrix(): boolean;
  39195. /**
  39196. * Attached controls to the current camera.
  39197. * @param element Defines the element the controls should be listened from
  39198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39199. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39200. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39201. */
  39202. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39203. /**
  39204. * Detach the current controls from the camera.
  39205. * The camera will stop reacting to inputs.
  39206. * @param element Defines the element to stop listening the inputs from
  39207. */
  39208. detachControl(element: HTMLElement): void;
  39209. /** @hidden */
  39210. _checkInputs(): void;
  39211. protected _checkLimits(): void;
  39212. /**
  39213. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39214. */
  39215. rebuildAnglesAndRadius(): void;
  39216. /**
  39217. * Use a position to define the current camera related information like alpha, beta and radius
  39218. * @param position Defines the position to set the camera at
  39219. */
  39220. setPosition(position: Vector3): void;
  39221. /**
  39222. * Defines the target the camera should look at.
  39223. * This will automatically adapt alpha beta and radius to fit within the new target.
  39224. * @param target Defines the new target as a Vector or a mesh
  39225. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39226. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39227. */
  39228. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39229. /** @hidden */
  39230. _getViewMatrix(): Matrix;
  39231. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39232. /**
  39233. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39234. * @param meshes Defines the mesh to zoom on
  39235. * @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)
  39236. */
  39237. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39238. /**
  39239. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39240. * The target will be changed but the radius
  39241. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39242. * @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)
  39243. */
  39244. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39245. min: Vector3;
  39246. max: Vector3;
  39247. distance: number;
  39248. }, doNotUpdateMaxZ?: boolean): void;
  39249. /**
  39250. * @override
  39251. * Override Camera.createRigCamera
  39252. */
  39253. createRigCamera(name: string, cameraIndex: number): Camera;
  39254. /**
  39255. * @hidden
  39256. * @override
  39257. * Override Camera._updateRigCameras
  39258. */
  39259. _updateRigCameras(): void;
  39260. /**
  39261. * Destroy the camera and release the current resources hold by it.
  39262. */
  39263. dispose(): void;
  39264. /**
  39265. * Gets the current object class name.
  39266. * @return the class name
  39267. */
  39268. getClassName(): string;
  39269. }
  39270. }
  39271. declare module BABYLON {
  39272. /**
  39273. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39275. */
  39276. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39277. /**
  39278. * Gets the name of the behavior.
  39279. */
  39280. get name(): string;
  39281. private _zoomStopsAnimation;
  39282. private _idleRotationSpeed;
  39283. private _idleRotationWaitTime;
  39284. private _idleRotationSpinupTime;
  39285. /**
  39286. * Sets the flag that indicates if user zooming should stop animation.
  39287. */
  39288. set zoomStopsAnimation(flag: boolean);
  39289. /**
  39290. * Gets the flag that indicates if user zooming should stop animation.
  39291. */
  39292. get zoomStopsAnimation(): boolean;
  39293. /**
  39294. * Sets the default speed at which the camera rotates around the model.
  39295. */
  39296. set idleRotationSpeed(speed: number);
  39297. /**
  39298. * Gets the default speed at which the camera rotates around the model.
  39299. */
  39300. get idleRotationSpeed(): number;
  39301. /**
  39302. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39303. */
  39304. set idleRotationWaitTime(time: number);
  39305. /**
  39306. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39307. */
  39308. get idleRotationWaitTime(): number;
  39309. /**
  39310. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39311. */
  39312. set idleRotationSpinupTime(time: number);
  39313. /**
  39314. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39315. */
  39316. get idleRotationSpinupTime(): number;
  39317. /**
  39318. * Gets a value indicating if the camera is currently rotating because of this behavior
  39319. */
  39320. get rotationInProgress(): boolean;
  39321. private _onPrePointerObservableObserver;
  39322. private _onAfterCheckInputsObserver;
  39323. private _attachedCamera;
  39324. private _isPointerDown;
  39325. private _lastFrameTime;
  39326. private _lastInteractionTime;
  39327. private _cameraRotationSpeed;
  39328. /**
  39329. * Initializes the behavior.
  39330. */
  39331. init(): void;
  39332. /**
  39333. * Attaches the behavior to its arc rotate camera.
  39334. * @param camera Defines the camera to attach the behavior to
  39335. */
  39336. attach(camera: ArcRotateCamera): void;
  39337. /**
  39338. * Detaches the behavior from its current arc rotate camera.
  39339. */
  39340. detach(): void;
  39341. /**
  39342. * Returns true if user is scrolling.
  39343. * @return true if user is scrolling.
  39344. */
  39345. private _userIsZooming;
  39346. private _lastFrameRadius;
  39347. private _shouldAnimationStopForInteraction;
  39348. /**
  39349. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39350. */
  39351. private _applyUserInteraction;
  39352. private _userIsMoving;
  39353. }
  39354. }
  39355. declare module BABYLON {
  39356. /**
  39357. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39358. */
  39359. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39360. private ui;
  39361. /**
  39362. * The name of the behavior
  39363. */
  39364. name: string;
  39365. /**
  39366. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39367. */
  39368. distanceAwayFromFace: number;
  39369. /**
  39370. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39371. */
  39372. distanceAwayFromBottomOfFace: number;
  39373. private _faceVectors;
  39374. private _target;
  39375. private _scene;
  39376. private _onRenderObserver;
  39377. private _tmpMatrix;
  39378. private _tmpVector;
  39379. /**
  39380. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39381. * @param ui The transform node that should be attched to the mesh
  39382. */
  39383. constructor(ui: TransformNode);
  39384. /**
  39385. * Initializes the behavior
  39386. */
  39387. init(): void;
  39388. private _closestFace;
  39389. private _zeroVector;
  39390. private _lookAtTmpMatrix;
  39391. private _lookAtToRef;
  39392. /**
  39393. * Attaches the AttachToBoxBehavior to the passed in mesh
  39394. * @param target The mesh that the specified node will be attached to
  39395. */
  39396. attach(target: Mesh): void;
  39397. /**
  39398. * Detaches the behavior from the mesh
  39399. */
  39400. detach(): void;
  39401. }
  39402. }
  39403. declare module BABYLON {
  39404. /**
  39405. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39406. */
  39407. export class FadeInOutBehavior implements Behavior<Mesh> {
  39408. /**
  39409. * Time in milliseconds to delay before fading in (Default: 0)
  39410. */
  39411. delay: number;
  39412. /**
  39413. * Time in milliseconds for the mesh to fade in (Default: 300)
  39414. */
  39415. fadeInTime: number;
  39416. private _millisecondsPerFrame;
  39417. private _hovered;
  39418. private _hoverValue;
  39419. private _ownerNode;
  39420. /**
  39421. * Instatiates the FadeInOutBehavior
  39422. */
  39423. constructor();
  39424. /**
  39425. * The name of the behavior
  39426. */
  39427. get name(): string;
  39428. /**
  39429. * Initializes the behavior
  39430. */
  39431. init(): void;
  39432. /**
  39433. * Attaches the fade behavior on the passed in mesh
  39434. * @param ownerNode The mesh that will be faded in/out once attached
  39435. */
  39436. attach(ownerNode: Mesh): void;
  39437. /**
  39438. * Detaches the behavior from the mesh
  39439. */
  39440. detach(): void;
  39441. /**
  39442. * Triggers the mesh to begin fading in or out
  39443. * @param value if the object should fade in or out (true to fade in)
  39444. */
  39445. fadeIn(value: boolean): void;
  39446. private _update;
  39447. private _setAllVisibility;
  39448. }
  39449. }
  39450. declare module BABYLON {
  39451. /**
  39452. * Class containing a set of static utilities functions for managing Pivots
  39453. * @hidden
  39454. */
  39455. export class PivotTools {
  39456. private static _PivotCached;
  39457. private static _OldPivotPoint;
  39458. private static _PivotTranslation;
  39459. private static _PivotTmpVector;
  39460. /** @hidden */
  39461. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39462. /** @hidden */
  39463. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /**
  39468. * Class containing static functions to help procedurally build meshes
  39469. */
  39470. export class PlaneBuilder {
  39471. /**
  39472. * Creates a plane mesh
  39473. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39474. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39475. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39477. * * 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
  39478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39479. * @param name defines the name of the mesh
  39480. * @param options defines the options used to create the mesh
  39481. * @param scene defines the hosting scene
  39482. * @returns the plane mesh
  39483. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39484. */
  39485. static CreatePlane(name: string, options: {
  39486. size?: number;
  39487. width?: number;
  39488. height?: number;
  39489. sideOrientation?: number;
  39490. frontUVs?: Vector4;
  39491. backUVs?: Vector4;
  39492. updatable?: boolean;
  39493. sourcePlane?: Plane;
  39494. }, scene?: Nullable<Scene>): Mesh;
  39495. }
  39496. }
  39497. declare module BABYLON {
  39498. /**
  39499. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39500. */
  39501. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39502. private static _AnyMouseID;
  39503. /**
  39504. * Abstract mesh the behavior is set on
  39505. */
  39506. attachedNode: AbstractMesh;
  39507. private _dragPlane;
  39508. private _scene;
  39509. private _pointerObserver;
  39510. private _beforeRenderObserver;
  39511. private static _planeScene;
  39512. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39513. /**
  39514. * 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)
  39515. */
  39516. maxDragAngle: number;
  39517. /**
  39518. * @hidden
  39519. */
  39520. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39521. /**
  39522. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39523. */
  39524. currentDraggingPointerID: number;
  39525. /**
  39526. * The last position where the pointer hit the drag plane in world space
  39527. */
  39528. lastDragPosition: Vector3;
  39529. /**
  39530. * If the behavior is currently in a dragging state
  39531. */
  39532. dragging: boolean;
  39533. /**
  39534. * 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)
  39535. */
  39536. dragDeltaRatio: number;
  39537. /**
  39538. * If the drag plane orientation should be updated during the dragging (Default: true)
  39539. */
  39540. updateDragPlane: boolean;
  39541. private _debugMode;
  39542. private _moving;
  39543. /**
  39544. * Fires each time the attached mesh is dragged with the pointer
  39545. * * delta between last drag position and current drag position in world space
  39546. * * dragDistance along the drag axis
  39547. * * dragPlaneNormal normal of the current drag plane used during the drag
  39548. * * dragPlanePoint in world space where the drag intersects the drag plane
  39549. */
  39550. onDragObservable: Observable<{
  39551. delta: Vector3;
  39552. dragPlanePoint: Vector3;
  39553. dragPlaneNormal: Vector3;
  39554. dragDistance: number;
  39555. pointerId: number;
  39556. }>;
  39557. /**
  39558. * Fires each time a drag begins (eg. mouse down on mesh)
  39559. */
  39560. onDragStartObservable: Observable<{
  39561. dragPlanePoint: Vector3;
  39562. pointerId: number;
  39563. }>;
  39564. /**
  39565. * Fires each time a drag ends (eg. mouse release after drag)
  39566. */
  39567. onDragEndObservable: Observable<{
  39568. dragPlanePoint: Vector3;
  39569. pointerId: number;
  39570. }>;
  39571. /**
  39572. * If the attached mesh should be moved when dragged
  39573. */
  39574. moveAttached: boolean;
  39575. /**
  39576. * If the drag behavior will react to drag events (Default: true)
  39577. */
  39578. enabled: boolean;
  39579. /**
  39580. * If pointer events should start and release the drag (Default: true)
  39581. */
  39582. startAndReleaseDragOnPointerEvents: boolean;
  39583. /**
  39584. * If camera controls should be detached during the drag
  39585. */
  39586. detachCameraControls: boolean;
  39587. /**
  39588. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39589. */
  39590. useObjectOrientationForDragging: boolean;
  39591. private _options;
  39592. /**
  39593. * Gets the options used by the behavior
  39594. */
  39595. get options(): {
  39596. dragAxis?: Vector3;
  39597. dragPlaneNormal?: Vector3;
  39598. };
  39599. /**
  39600. * Sets the options used by the behavior
  39601. */
  39602. set options(options: {
  39603. dragAxis?: Vector3;
  39604. dragPlaneNormal?: Vector3;
  39605. });
  39606. /**
  39607. * Creates a pointer drag behavior that can be attached to a mesh
  39608. * @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)
  39609. */
  39610. constructor(options?: {
  39611. dragAxis?: Vector3;
  39612. dragPlaneNormal?: Vector3;
  39613. });
  39614. /**
  39615. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39616. */
  39617. validateDrag: (targetPosition: Vector3) => boolean;
  39618. /**
  39619. * The name of the behavior
  39620. */
  39621. get name(): string;
  39622. /**
  39623. * Initializes the behavior
  39624. */
  39625. init(): void;
  39626. private _tmpVector;
  39627. private _alternatePickedPoint;
  39628. private _worldDragAxis;
  39629. private _targetPosition;
  39630. private _attachedElement;
  39631. /**
  39632. * Attaches the drag behavior the passed in mesh
  39633. * @param ownerNode The mesh that will be dragged around once attached
  39634. * @param predicate Predicate to use for pick filtering
  39635. */
  39636. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39637. /**
  39638. * Force relase the drag action by code.
  39639. */
  39640. releaseDrag(): void;
  39641. private _startDragRay;
  39642. private _lastPointerRay;
  39643. /**
  39644. * Simulates the start of a pointer drag event on the behavior
  39645. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39646. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39647. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39648. */
  39649. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39650. private _startDrag;
  39651. private _dragDelta;
  39652. private _moveDrag;
  39653. private _pickWithRayOnDragPlane;
  39654. private _pointA;
  39655. private _pointB;
  39656. private _pointC;
  39657. private _lineA;
  39658. private _lineB;
  39659. private _localAxis;
  39660. private _lookAt;
  39661. private _updateDragPlanePosition;
  39662. /**
  39663. * Detaches the behavior from the mesh
  39664. */
  39665. detach(): void;
  39666. }
  39667. }
  39668. declare module BABYLON {
  39669. /**
  39670. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39671. */
  39672. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39673. private _dragBehaviorA;
  39674. private _dragBehaviorB;
  39675. private _startDistance;
  39676. private _initialScale;
  39677. private _targetScale;
  39678. private _ownerNode;
  39679. private _sceneRenderObserver;
  39680. /**
  39681. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39682. */
  39683. constructor();
  39684. /**
  39685. * The name of the behavior
  39686. */
  39687. get name(): string;
  39688. /**
  39689. * Initializes the behavior
  39690. */
  39691. init(): void;
  39692. private _getCurrentDistance;
  39693. /**
  39694. * Attaches the scale behavior the passed in mesh
  39695. * @param ownerNode The mesh that will be scaled around once attached
  39696. */
  39697. attach(ownerNode: Mesh): void;
  39698. /**
  39699. * Detaches the behavior from the mesh
  39700. */
  39701. detach(): void;
  39702. }
  39703. }
  39704. declare module BABYLON {
  39705. /**
  39706. * 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
  39707. */
  39708. export class SixDofDragBehavior implements Behavior<Mesh> {
  39709. private static _virtualScene;
  39710. private _ownerNode;
  39711. private _sceneRenderObserver;
  39712. private _scene;
  39713. private _targetPosition;
  39714. private _virtualOriginMesh;
  39715. private _virtualDragMesh;
  39716. private _pointerObserver;
  39717. private _moving;
  39718. private _startingOrientation;
  39719. private _attachedElement;
  39720. /**
  39721. * 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)
  39722. */
  39723. private zDragFactor;
  39724. /**
  39725. * If the object should rotate to face the drag origin
  39726. */
  39727. rotateDraggedObject: boolean;
  39728. /**
  39729. * If the behavior is currently in a dragging state
  39730. */
  39731. dragging: boolean;
  39732. /**
  39733. * 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)
  39734. */
  39735. dragDeltaRatio: number;
  39736. /**
  39737. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39738. */
  39739. currentDraggingPointerID: number;
  39740. /**
  39741. * If camera controls should be detached during the drag
  39742. */
  39743. detachCameraControls: boolean;
  39744. /**
  39745. * Fires each time a drag starts
  39746. */
  39747. onDragStartObservable: Observable<{}>;
  39748. /**
  39749. * Fires each time a drag ends (eg. mouse release after drag)
  39750. */
  39751. onDragEndObservable: Observable<{}>;
  39752. /**
  39753. * 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
  39754. */
  39755. constructor();
  39756. /**
  39757. * The name of the behavior
  39758. */
  39759. get name(): string;
  39760. /**
  39761. * Initializes the behavior
  39762. */
  39763. init(): void;
  39764. /**
  39765. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39766. */
  39767. private get _pointerCamera();
  39768. /**
  39769. * Attaches the scale behavior the passed in mesh
  39770. * @param ownerNode The mesh that will be scaled around once attached
  39771. */
  39772. attach(ownerNode: Mesh): void;
  39773. /**
  39774. * Detaches the behavior from the mesh
  39775. */
  39776. detach(): void;
  39777. }
  39778. }
  39779. declare module BABYLON {
  39780. /**
  39781. * Class used to apply inverse kinematics to bones
  39782. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39783. */
  39784. export class BoneIKController {
  39785. private static _tmpVecs;
  39786. private static _tmpQuat;
  39787. private static _tmpMats;
  39788. /**
  39789. * Gets or sets the target mesh
  39790. */
  39791. targetMesh: AbstractMesh;
  39792. /** Gets or sets the mesh used as pole */
  39793. poleTargetMesh: AbstractMesh;
  39794. /**
  39795. * Gets or sets the bone used as pole
  39796. */
  39797. poleTargetBone: Nullable<Bone>;
  39798. /**
  39799. * Gets or sets the target position
  39800. */
  39801. targetPosition: Vector3;
  39802. /**
  39803. * Gets or sets the pole target position
  39804. */
  39805. poleTargetPosition: Vector3;
  39806. /**
  39807. * Gets or sets the pole target local offset
  39808. */
  39809. poleTargetLocalOffset: Vector3;
  39810. /**
  39811. * Gets or sets the pole angle
  39812. */
  39813. poleAngle: number;
  39814. /**
  39815. * Gets or sets the mesh associated with the controller
  39816. */
  39817. mesh: AbstractMesh;
  39818. /**
  39819. * 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)
  39820. */
  39821. slerpAmount: number;
  39822. private _bone1Quat;
  39823. private _bone1Mat;
  39824. private _bone2Ang;
  39825. private _bone1;
  39826. private _bone2;
  39827. private _bone1Length;
  39828. private _bone2Length;
  39829. private _maxAngle;
  39830. private _maxReach;
  39831. private _rightHandedSystem;
  39832. private _bendAxis;
  39833. private _slerping;
  39834. private _adjustRoll;
  39835. /**
  39836. * Gets or sets maximum allowed angle
  39837. */
  39838. get maxAngle(): number;
  39839. set maxAngle(value: number);
  39840. /**
  39841. * Creates a new BoneIKController
  39842. * @param mesh defines the mesh to control
  39843. * @param bone defines the bone to control
  39844. * @param options defines options to set up the controller
  39845. */
  39846. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39847. targetMesh?: AbstractMesh;
  39848. poleTargetMesh?: AbstractMesh;
  39849. poleTargetBone?: Bone;
  39850. poleTargetLocalOffset?: Vector3;
  39851. poleAngle?: number;
  39852. bendAxis?: Vector3;
  39853. maxAngle?: number;
  39854. slerpAmount?: number;
  39855. });
  39856. private _setMaxAngle;
  39857. /**
  39858. * Force the controller to update the bones
  39859. */
  39860. update(): void;
  39861. }
  39862. }
  39863. declare module BABYLON {
  39864. /**
  39865. * Class used to make a bone look toward a point in space
  39866. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39867. */
  39868. export class BoneLookController {
  39869. private static _tmpVecs;
  39870. private static _tmpQuat;
  39871. private static _tmpMats;
  39872. /**
  39873. * The target Vector3 that the bone will look at
  39874. */
  39875. target: Vector3;
  39876. /**
  39877. * The mesh that the bone is attached to
  39878. */
  39879. mesh: AbstractMesh;
  39880. /**
  39881. * The bone that will be looking to the target
  39882. */
  39883. bone: Bone;
  39884. /**
  39885. * The up axis of the coordinate system that is used when the bone is rotated
  39886. */
  39887. upAxis: Vector3;
  39888. /**
  39889. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39890. */
  39891. upAxisSpace: Space;
  39892. /**
  39893. * Used to make an adjustment to the yaw of the bone
  39894. */
  39895. adjustYaw: number;
  39896. /**
  39897. * Used to make an adjustment to the pitch of the bone
  39898. */
  39899. adjustPitch: number;
  39900. /**
  39901. * Used to make an adjustment to the roll of the bone
  39902. */
  39903. adjustRoll: number;
  39904. /**
  39905. * 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)
  39906. */
  39907. slerpAmount: number;
  39908. private _minYaw;
  39909. private _maxYaw;
  39910. private _minPitch;
  39911. private _maxPitch;
  39912. private _minYawSin;
  39913. private _minYawCos;
  39914. private _maxYawSin;
  39915. private _maxYawCos;
  39916. private _midYawConstraint;
  39917. private _minPitchTan;
  39918. private _maxPitchTan;
  39919. private _boneQuat;
  39920. private _slerping;
  39921. private _transformYawPitch;
  39922. private _transformYawPitchInv;
  39923. private _firstFrameSkipped;
  39924. private _yawRange;
  39925. private _fowardAxis;
  39926. /**
  39927. * Gets or sets the minimum yaw angle that the bone can look to
  39928. */
  39929. get minYaw(): number;
  39930. set minYaw(value: number);
  39931. /**
  39932. * Gets or sets the maximum yaw angle that the bone can look to
  39933. */
  39934. get maxYaw(): number;
  39935. set maxYaw(value: number);
  39936. /**
  39937. * Gets or sets the minimum pitch angle that the bone can look to
  39938. */
  39939. get minPitch(): number;
  39940. set minPitch(value: number);
  39941. /**
  39942. * Gets or sets the maximum pitch angle that the bone can look to
  39943. */
  39944. get maxPitch(): number;
  39945. set maxPitch(value: number);
  39946. /**
  39947. * Create a BoneLookController
  39948. * @param mesh the mesh that the bone belongs to
  39949. * @param bone the bone that will be looking to the target
  39950. * @param target the target Vector3 to look at
  39951. * @param options optional settings:
  39952. * * maxYaw: the maximum angle the bone will yaw to
  39953. * * minYaw: the minimum angle the bone will yaw to
  39954. * * maxPitch: the maximum angle the bone will pitch to
  39955. * * minPitch: the minimum angle the bone will yaw to
  39956. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39957. * * upAxis: the up axis of the coordinate system
  39958. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39959. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39960. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39961. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39962. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39963. * * adjustRoll: used to make an adjustment to the roll of the bone
  39964. **/
  39965. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39966. maxYaw?: number;
  39967. minYaw?: number;
  39968. maxPitch?: number;
  39969. minPitch?: number;
  39970. slerpAmount?: number;
  39971. upAxis?: Vector3;
  39972. upAxisSpace?: Space;
  39973. yawAxis?: Vector3;
  39974. pitchAxis?: Vector3;
  39975. adjustYaw?: number;
  39976. adjustPitch?: number;
  39977. adjustRoll?: number;
  39978. });
  39979. /**
  39980. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39981. */
  39982. update(): void;
  39983. private _getAngleDiff;
  39984. private _getAngleBetween;
  39985. private _isAngleBetween;
  39986. }
  39987. }
  39988. declare module BABYLON {
  39989. /**
  39990. * Manage the gamepad inputs to control an arc rotate camera.
  39991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39992. */
  39993. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39994. /**
  39995. * Defines the camera the input is attached to.
  39996. */
  39997. camera: ArcRotateCamera;
  39998. /**
  39999. * Defines the gamepad the input is gathering event from.
  40000. */
  40001. gamepad: Nullable<Gamepad>;
  40002. /**
  40003. * Defines the gamepad rotation sensiblity.
  40004. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40005. */
  40006. gamepadRotationSensibility: number;
  40007. /**
  40008. * Defines the gamepad move sensiblity.
  40009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40010. */
  40011. gamepadMoveSensibility: number;
  40012. private _yAxisScale;
  40013. /**
  40014. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40015. */
  40016. get invertYAxis(): boolean;
  40017. set invertYAxis(value: boolean);
  40018. private _onGamepadConnectedObserver;
  40019. private _onGamepadDisconnectedObserver;
  40020. /**
  40021. * Attach the input controls to a specific dom element to get the input from.
  40022. * @param element Defines the element the controls should be listened from
  40023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40024. */
  40025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40026. /**
  40027. * Detach the current controls from the specified dom element.
  40028. * @param element Defines the element to stop listening the inputs from
  40029. */
  40030. detachControl(element: Nullable<HTMLElement>): void;
  40031. /**
  40032. * Update the current camera state depending on the inputs that have been used this frame.
  40033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40034. */
  40035. checkInputs(): void;
  40036. /**
  40037. * Gets the class name of the current intput.
  40038. * @returns the class name
  40039. */
  40040. getClassName(): string;
  40041. /**
  40042. * Get the friendly name associated with the input class.
  40043. * @returns the input friendly name
  40044. */
  40045. getSimpleName(): string;
  40046. }
  40047. }
  40048. declare module BABYLON {
  40049. interface ArcRotateCameraInputsManager {
  40050. /**
  40051. * Add orientation input support to the input manager.
  40052. * @returns the current input manager
  40053. */
  40054. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40055. }
  40056. /**
  40057. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40059. */
  40060. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40061. /**
  40062. * Defines the camera the input is attached to.
  40063. */
  40064. camera: ArcRotateCamera;
  40065. /**
  40066. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40067. */
  40068. alphaCorrection: number;
  40069. /**
  40070. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40071. */
  40072. gammaCorrection: number;
  40073. private _alpha;
  40074. private _gamma;
  40075. private _dirty;
  40076. private _deviceOrientationHandler;
  40077. /**
  40078. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40079. */
  40080. constructor();
  40081. /**
  40082. * Attach the input controls to a specific dom element to get the input from.
  40083. * @param element Defines the element the controls should be listened from
  40084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40085. */
  40086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40087. /** @hidden */
  40088. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40089. /**
  40090. * Update the current camera state depending on the inputs that have been used this frame.
  40091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40092. */
  40093. checkInputs(): void;
  40094. /**
  40095. * Detach the current controls from the specified dom element.
  40096. * @param element Defines the element to stop listening the inputs from
  40097. */
  40098. detachControl(element: Nullable<HTMLElement>): void;
  40099. /**
  40100. * Gets the class name of the current intput.
  40101. * @returns the class name
  40102. */
  40103. getClassName(): string;
  40104. /**
  40105. * Get the friendly name associated with the input class.
  40106. * @returns the input friendly name
  40107. */
  40108. getSimpleName(): string;
  40109. }
  40110. }
  40111. declare module BABYLON {
  40112. /**
  40113. * Listen to mouse events to control the camera.
  40114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40115. */
  40116. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40117. /**
  40118. * Defines the camera the input is attached to.
  40119. */
  40120. camera: FlyCamera;
  40121. /**
  40122. * Defines if touch is enabled. (Default is true.)
  40123. */
  40124. touchEnabled: boolean;
  40125. /**
  40126. * Defines the buttons associated with the input to handle camera rotation.
  40127. */
  40128. buttons: number[];
  40129. /**
  40130. * Assign buttons for Yaw control.
  40131. */
  40132. buttonsYaw: number[];
  40133. /**
  40134. * Assign buttons for Pitch control.
  40135. */
  40136. buttonsPitch: number[];
  40137. /**
  40138. * Assign buttons for Roll control.
  40139. */
  40140. buttonsRoll: number[];
  40141. /**
  40142. * Detect if any button is being pressed while mouse is moved.
  40143. * -1 = Mouse locked.
  40144. * 0 = Left button.
  40145. * 1 = Middle Button.
  40146. * 2 = Right Button.
  40147. */
  40148. activeButton: number;
  40149. /**
  40150. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40151. * Higher values reduce its sensitivity.
  40152. */
  40153. angularSensibility: number;
  40154. private _mousemoveCallback;
  40155. private _observer;
  40156. private _rollObserver;
  40157. private previousPosition;
  40158. private noPreventDefault;
  40159. private element;
  40160. /**
  40161. * Listen to mouse events to control the camera.
  40162. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40164. */
  40165. constructor(touchEnabled?: boolean);
  40166. /**
  40167. * Attach the mouse control to the HTML DOM element.
  40168. * @param element Defines the element that listens to the input events.
  40169. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40170. */
  40171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40172. /**
  40173. * Detach the current controls from the specified dom element.
  40174. * @param element Defines the element to stop listening the inputs from
  40175. */
  40176. detachControl(element: Nullable<HTMLElement>): void;
  40177. /**
  40178. * Gets the class name of the current input.
  40179. * @returns the class name.
  40180. */
  40181. getClassName(): string;
  40182. /**
  40183. * Get the friendly name associated with the input class.
  40184. * @returns the input's friendly name.
  40185. */
  40186. getSimpleName(): string;
  40187. private _pointerInput;
  40188. private _onMouseMove;
  40189. /**
  40190. * Rotate camera by mouse offset.
  40191. */
  40192. private rotateCamera;
  40193. }
  40194. }
  40195. declare module BABYLON {
  40196. /**
  40197. * Default Inputs manager for the FlyCamera.
  40198. * It groups all the default supported inputs for ease of use.
  40199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40200. */
  40201. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40202. /**
  40203. * Instantiates a new FlyCameraInputsManager.
  40204. * @param camera Defines the camera the inputs belong to.
  40205. */
  40206. constructor(camera: FlyCamera);
  40207. /**
  40208. * Add keyboard input support to the input manager.
  40209. * @returns the new FlyCameraKeyboardMoveInput().
  40210. */
  40211. addKeyboard(): FlyCameraInputsManager;
  40212. /**
  40213. * Add mouse input support to the input manager.
  40214. * @param touchEnabled Enable touch screen support.
  40215. * @returns the new FlyCameraMouseInput().
  40216. */
  40217. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40218. }
  40219. }
  40220. declare module BABYLON {
  40221. /**
  40222. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40223. * such as in a 3D Space Shooter or a Flight Simulator.
  40224. */
  40225. export class FlyCamera extends TargetCamera {
  40226. /**
  40227. * Define the collision ellipsoid of the camera.
  40228. * This is helpful for simulating a camera body, like a player's body.
  40229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40230. */
  40231. ellipsoid: Vector3;
  40232. /**
  40233. * Define an offset for the position of the ellipsoid around the camera.
  40234. * This can be helpful if the camera is attached away from the player's body center,
  40235. * such as at its head.
  40236. */
  40237. ellipsoidOffset: Vector3;
  40238. /**
  40239. * Enable or disable collisions of the camera with the rest of the scene objects.
  40240. */
  40241. checkCollisions: boolean;
  40242. /**
  40243. * Enable or disable gravity on the camera.
  40244. */
  40245. applyGravity: boolean;
  40246. /**
  40247. * Define the current direction the camera is moving to.
  40248. */
  40249. cameraDirection: Vector3;
  40250. /**
  40251. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40252. * This overrides and empties cameraRotation.
  40253. */
  40254. rotationQuaternion: Quaternion;
  40255. /**
  40256. * Track Roll to maintain the wanted Rolling when looking around.
  40257. */
  40258. _trackRoll: number;
  40259. /**
  40260. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40261. */
  40262. rollCorrect: number;
  40263. /**
  40264. * Mimic a banked turn, Rolling the camera when Yawing.
  40265. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40266. */
  40267. bankedTurn: boolean;
  40268. /**
  40269. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40270. */
  40271. bankedTurnLimit: number;
  40272. /**
  40273. * Value of 0 disables the banked Roll.
  40274. * Value of 1 is equal to the Yaw angle in radians.
  40275. */
  40276. bankedTurnMultiplier: number;
  40277. /**
  40278. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40279. */
  40280. inputs: FlyCameraInputsManager;
  40281. /**
  40282. * Gets the input sensibility for mouse input.
  40283. * Higher values reduce sensitivity.
  40284. */
  40285. get angularSensibility(): number;
  40286. /**
  40287. * Sets the input sensibility for a mouse input.
  40288. * Higher values reduce sensitivity.
  40289. */
  40290. set angularSensibility(value: number);
  40291. /**
  40292. * Get the keys for camera movement forward.
  40293. */
  40294. get keysForward(): number[];
  40295. /**
  40296. * Set the keys for camera movement forward.
  40297. */
  40298. set keysForward(value: number[]);
  40299. /**
  40300. * Get the keys for camera movement backward.
  40301. */
  40302. get keysBackward(): number[];
  40303. set keysBackward(value: number[]);
  40304. /**
  40305. * Get the keys for camera movement up.
  40306. */
  40307. get keysUp(): number[];
  40308. /**
  40309. * Set the keys for camera movement up.
  40310. */
  40311. set keysUp(value: number[]);
  40312. /**
  40313. * Get the keys for camera movement down.
  40314. */
  40315. get keysDown(): number[];
  40316. /**
  40317. * Set the keys for camera movement down.
  40318. */
  40319. set keysDown(value: number[]);
  40320. /**
  40321. * Get the keys for camera movement left.
  40322. */
  40323. get keysLeft(): number[];
  40324. /**
  40325. * Set the keys for camera movement left.
  40326. */
  40327. set keysLeft(value: number[]);
  40328. /**
  40329. * Set the keys for camera movement right.
  40330. */
  40331. get keysRight(): number[];
  40332. /**
  40333. * Set the keys for camera movement right.
  40334. */
  40335. set keysRight(value: number[]);
  40336. /**
  40337. * Event raised when the camera collides with a mesh in the scene.
  40338. */
  40339. onCollide: (collidedMesh: AbstractMesh) => void;
  40340. private _collider;
  40341. private _needMoveForGravity;
  40342. private _oldPosition;
  40343. private _diffPosition;
  40344. private _newPosition;
  40345. /** @hidden */
  40346. _localDirection: Vector3;
  40347. /** @hidden */
  40348. _transformedDirection: Vector3;
  40349. /**
  40350. * Instantiates a FlyCamera.
  40351. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40352. * such as in a 3D Space Shooter or a Flight Simulator.
  40353. * @param name Define the name of the camera in the scene.
  40354. * @param position Define the starting position of the camera in the scene.
  40355. * @param scene Define the scene the camera belongs to.
  40356. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40357. */
  40358. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40359. /**
  40360. * Attach a control to the HTML DOM element.
  40361. * @param element Defines the element that listens to the input events.
  40362. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40363. */
  40364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40365. /**
  40366. * Detach a control from the HTML DOM element.
  40367. * The camera will stop reacting to that input.
  40368. * @param element Defines the element that listens to the input events.
  40369. */
  40370. detachControl(element: HTMLElement): void;
  40371. private _collisionMask;
  40372. /**
  40373. * Get the mask that the camera ignores in collision events.
  40374. */
  40375. get collisionMask(): number;
  40376. /**
  40377. * Set the mask that the camera ignores in collision events.
  40378. */
  40379. set collisionMask(mask: number);
  40380. /** @hidden */
  40381. _collideWithWorld(displacement: Vector3): void;
  40382. /** @hidden */
  40383. private _onCollisionPositionChange;
  40384. /** @hidden */
  40385. _checkInputs(): void;
  40386. /** @hidden */
  40387. _decideIfNeedsToMove(): boolean;
  40388. /** @hidden */
  40389. _updatePosition(): void;
  40390. /**
  40391. * Restore the Roll to its target value at the rate specified.
  40392. * @param rate - Higher means slower restoring.
  40393. * @hidden
  40394. */
  40395. restoreRoll(rate: number): void;
  40396. /**
  40397. * Destroy the camera and release the current resources held by it.
  40398. */
  40399. dispose(): void;
  40400. /**
  40401. * Get the current object class name.
  40402. * @returns the class name.
  40403. */
  40404. getClassName(): string;
  40405. }
  40406. }
  40407. declare module BABYLON {
  40408. /**
  40409. * Listen to keyboard events to control the camera.
  40410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40411. */
  40412. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40413. /**
  40414. * Defines the camera the input is attached to.
  40415. */
  40416. camera: FlyCamera;
  40417. /**
  40418. * The list of keyboard keys used to control the forward move of the camera.
  40419. */
  40420. keysForward: number[];
  40421. /**
  40422. * The list of keyboard keys used to control the backward move of the camera.
  40423. */
  40424. keysBackward: number[];
  40425. /**
  40426. * The list of keyboard keys used to control the forward move of the camera.
  40427. */
  40428. keysUp: number[];
  40429. /**
  40430. * The list of keyboard keys used to control the backward move of the camera.
  40431. */
  40432. keysDown: number[];
  40433. /**
  40434. * The list of keyboard keys used to control the right strafe move of the camera.
  40435. */
  40436. keysRight: number[];
  40437. /**
  40438. * The list of keyboard keys used to control the left strafe move of the camera.
  40439. */
  40440. keysLeft: number[];
  40441. private _keys;
  40442. private _onCanvasBlurObserver;
  40443. private _onKeyboardObserver;
  40444. private _engine;
  40445. private _scene;
  40446. /**
  40447. * Attach the input controls to a specific dom element to get the input from.
  40448. * @param element Defines the element the controls should be listened from
  40449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40450. */
  40451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40452. /**
  40453. * Detach the current controls from the specified dom element.
  40454. * @param element Defines the element to stop listening the inputs from
  40455. */
  40456. detachControl(element: Nullable<HTMLElement>): void;
  40457. /**
  40458. * Gets the class name of the current intput.
  40459. * @returns the class name
  40460. */
  40461. getClassName(): string;
  40462. /** @hidden */
  40463. _onLostFocus(e: FocusEvent): void;
  40464. /**
  40465. * Get the friendly name associated with the input class.
  40466. * @returns the input friendly name
  40467. */
  40468. getSimpleName(): string;
  40469. /**
  40470. * Update the current camera state depending on the inputs that have been used this frame.
  40471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40472. */
  40473. checkInputs(): void;
  40474. }
  40475. }
  40476. declare module BABYLON {
  40477. /**
  40478. * Manage the mouse wheel inputs to control a follow camera.
  40479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40480. */
  40481. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40482. /**
  40483. * Defines the camera the input is attached to.
  40484. */
  40485. camera: FollowCamera;
  40486. /**
  40487. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40488. */
  40489. axisControlRadius: boolean;
  40490. /**
  40491. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40492. */
  40493. axisControlHeight: boolean;
  40494. /**
  40495. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40496. */
  40497. axisControlRotation: boolean;
  40498. /**
  40499. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40500. * relation to mouseWheel events.
  40501. */
  40502. wheelPrecision: number;
  40503. /**
  40504. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40505. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40506. */
  40507. wheelDeltaPercentage: number;
  40508. private _wheel;
  40509. private _observer;
  40510. /**
  40511. * Attach the input controls to a specific dom element to get the input from.
  40512. * @param element Defines the element the controls should be listened from
  40513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40514. */
  40515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40516. /**
  40517. * Detach the current controls from the specified dom element.
  40518. * @param element Defines the element to stop listening the inputs from
  40519. */
  40520. detachControl(element: Nullable<HTMLElement>): void;
  40521. /**
  40522. * Gets the class name of the current intput.
  40523. * @returns the class name
  40524. */
  40525. getClassName(): string;
  40526. /**
  40527. * Get the friendly name associated with the input class.
  40528. * @returns the input friendly name
  40529. */
  40530. getSimpleName(): string;
  40531. }
  40532. }
  40533. declare module BABYLON {
  40534. /**
  40535. * Manage the pointers inputs to control an follow camera.
  40536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40537. */
  40538. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40539. /**
  40540. * Defines the camera the input is attached to.
  40541. */
  40542. camera: FollowCamera;
  40543. /**
  40544. * Gets the class name of the current input.
  40545. * @returns the class name
  40546. */
  40547. getClassName(): string;
  40548. /**
  40549. * Defines the pointer angular sensibility along the X axis or how fast is
  40550. * the camera rotating.
  40551. * A negative number will reverse the axis direction.
  40552. */
  40553. angularSensibilityX: number;
  40554. /**
  40555. * Defines the pointer angular sensibility along the Y axis or how fast is
  40556. * the camera rotating.
  40557. * A negative number will reverse the axis direction.
  40558. */
  40559. angularSensibilityY: number;
  40560. /**
  40561. * Defines the pointer pinch precision or how fast is the camera zooming.
  40562. * A negative number will reverse the axis direction.
  40563. */
  40564. pinchPrecision: number;
  40565. /**
  40566. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40567. * from 0.
  40568. * It defines the percentage of current camera.radius to use as delta when
  40569. * pinch zoom is used.
  40570. */
  40571. pinchDeltaPercentage: number;
  40572. /**
  40573. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40574. */
  40575. axisXControlRadius: boolean;
  40576. /**
  40577. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40578. */
  40579. axisXControlHeight: boolean;
  40580. /**
  40581. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40582. */
  40583. axisXControlRotation: boolean;
  40584. /**
  40585. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40586. */
  40587. axisYControlRadius: boolean;
  40588. /**
  40589. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40590. */
  40591. axisYControlHeight: boolean;
  40592. /**
  40593. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40594. */
  40595. axisYControlRotation: boolean;
  40596. /**
  40597. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40598. */
  40599. axisPinchControlRadius: boolean;
  40600. /**
  40601. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40602. */
  40603. axisPinchControlHeight: boolean;
  40604. /**
  40605. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40606. */
  40607. axisPinchControlRotation: boolean;
  40608. /**
  40609. * Log error messages if basic misconfiguration has occurred.
  40610. */
  40611. warningEnable: boolean;
  40612. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40613. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40614. private _warningCounter;
  40615. private _warning;
  40616. }
  40617. }
  40618. declare module BABYLON {
  40619. /**
  40620. * Default Inputs manager for the FollowCamera.
  40621. * It groups all the default supported inputs for ease of use.
  40622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40623. */
  40624. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40625. /**
  40626. * Instantiates a new FollowCameraInputsManager.
  40627. * @param camera Defines the camera the inputs belong to
  40628. */
  40629. constructor(camera: FollowCamera);
  40630. /**
  40631. * Add keyboard input support to the input manager.
  40632. * @returns the current input manager
  40633. */
  40634. addKeyboard(): FollowCameraInputsManager;
  40635. /**
  40636. * Add mouse wheel input support to the input manager.
  40637. * @returns the current input manager
  40638. */
  40639. addMouseWheel(): FollowCameraInputsManager;
  40640. /**
  40641. * Add pointers input support to the input manager.
  40642. * @returns the current input manager
  40643. */
  40644. addPointers(): FollowCameraInputsManager;
  40645. /**
  40646. * Add orientation input support to the input manager.
  40647. * @returns the current input manager
  40648. */
  40649. addVRDeviceOrientation(): FollowCameraInputsManager;
  40650. }
  40651. }
  40652. declare module BABYLON {
  40653. /**
  40654. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40655. * an arc rotate version arcFollowCamera are available.
  40656. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40657. */
  40658. export class FollowCamera extends TargetCamera {
  40659. /**
  40660. * Distance the follow camera should follow an object at
  40661. */
  40662. radius: number;
  40663. /**
  40664. * Minimum allowed distance of the camera to the axis of rotation
  40665. * (The camera can not get closer).
  40666. * This can help limiting how the Camera is able to move in the scene.
  40667. */
  40668. lowerRadiusLimit: Nullable<number>;
  40669. /**
  40670. * Maximum allowed distance of the camera to the axis of rotation
  40671. * (The camera can not get further).
  40672. * This can help limiting how the Camera is able to move in the scene.
  40673. */
  40674. upperRadiusLimit: Nullable<number>;
  40675. /**
  40676. * Define a rotation offset between the camera and the object it follows
  40677. */
  40678. rotationOffset: number;
  40679. /**
  40680. * Minimum allowed angle to camera position relative to target object.
  40681. * This can help limiting how the Camera is able to move in the scene.
  40682. */
  40683. lowerRotationOffsetLimit: Nullable<number>;
  40684. /**
  40685. * Maximum allowed angle to camera position relative to target object.
  40686. * This can help limiting how the Camera is able to move in the scene.
  40687. */
  40688. upperRotationOffsetLimit: Nullable<number>;
  40689. /**
  40690. * Define a height offset between the camera and the object it follows.
  40691. * It can help following an object from the top (like a car chaing a plane)
  40692. */
  40693. heightOffset: number;
  40694. /**
  40695. * Minimum allowed height of camera position relative to target object.
  40696. * This can help limiting how the Camera is able to move in the scene.
  40697. */
  40698. lowerHeightOffsetLimit: Nullable<number>;
  40699. /**
  40700. * Maximum allowed height of camera position relative to target object.
  40701. * This can help limiting how the Camera is able to move in the scene.
  40702. */
  40703. upperHeightOffsetLimit: Nullable<number>;
  40704. /**
  40705. * Define how fast the camera can accelerate to follow it s target.
  40706. */
  40707. cameraAcceleration: number;
  40708. /**
  40709. * Define the speed limit of the camera following an object.
  40710. */
  40711. maxCameraSpeed: number;
  40712. /**
  40713. * Define the target of the camera.
  40714. */
  40715. lockedTarget: Nullable<AbstractMesh>;
  40716. /**
  40717. * Defines the input associated with the camera.
  40718. */
  40719. inputs: FollowCameraInputsManager;
  40720. /**
  40721. * Instantiates the follow camera.
  40722. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40723. * @param name Define the name of the camera in the scene
  40724. * @param position Define the position of the camera
  40725. * @param scene Define the scene the camera belong to
  40726. * @param lockedTarget Define the target of the camera
  40727. */
  40728. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40729. private _follow;
  40730. /**
  40731. * Attached controls to the current camera.
  40732. * @param element Defines the element the controls should be listened from
  40733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40734. */
  40735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40736. /**
  40737. * Detach the current controls from the camera.
  40738. * The camera will stop reacting to inputs.
  40739. * @param element Defines the element to stop listening the inputs from
  40740. */
  40741. detachControl(element: HTMLElement): void;
  40742. /** @hidden */
  40743. _checkInputs(): void;
  40744. private _checkLimits;
  40745. /**
  40746. * Gets the camera class name.
  40747. * @returns the class name
  40748. */
  40749. getClassName(): string;
  40750. }
  40751. /**
  40752. * Arc Rotate version of the follow camera.
  40753. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40754. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40755. */
  40756. export class ArcFollowCamera extends TargetCamera {
  40757. /** The longitudinal angle of the camera */
  40758. alpha: number;
  40759. /** The latitudinal angle of the camera */
  40760. beta: number;
  40761. /** The radius of the camera from its target */
  40762. radius: number;
  40763. /** Define the camera target (the messh it should follow) */
  40764. target: Nullable<AbstractMesh>;
  40765. private _cartesianCoordinates;
  40766. /**
  40767. * Instantiates a new ArcFollowCamera
  40768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40769. * @param name Define the name of the camera
  40770. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40771. * @param beta Define the rotation angle of the camera around the elevation axis
  40772. * @param radius Define the radius of the camera from its target point
  40773. * @param target Define the target of the camera
  40774. * @param scene Define the scene the camera belongs to
  40775. */
  40776. constructor(name: string,
  40777. /** The longitudinal angle of the camera */
  40778. alpha: number,
  40779. /** The latitudinal angle of the camera */
  40780. beta: number,
  40781. /** The radius of the camera from its target */
  40782. radius: number,
  40783. /** Define the camera target (the messh it should follow) */
  40784. target: Nullable<AbstractMesh>, scene: Scene);
  40785. private _follow;
  40786. /** @hidden */
  40787. _checkInputs(): void;
  40788. /**
  40789. * Returns the class name of the object.
  40790. * It is mostly used internally for serialization purposes.
  40791. */
  40792. getClassName(): string;
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. /**
  40797. * Manage the keyboard inputs to control the movement of a follow camera.
  40798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40799. */
  40800. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40801. /**
  40802. * Defines the camera the input is attached to.
  40803. */
  40804. camera: FollowCamera;
  40805. /**
  40806. * Defines the list of key codes associated with the up action (increase heightOffset)
  40807. */
  40808. keysHeightOffsetIncr: number[];
  40809. /**
  40810. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40811. */
  40812. keysHeightOffsetDecr: number[];
  40813. /**
  40814. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40815. */
  40816. keysHeightOffsetModifierAlt: boolean;
  40817. /**
  40818. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40819. */
  40820. keysHeightOffsetModifierCtrl: boolean;
  40821. /**
  40822. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40823. */
  40824. keysHeightOffsetModifierShift: boolean;
  40825. /**
  40826. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40827. */
  40828. keysRotationOffsetIncr: number[];
  40829. /**
  40830. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40831. */
  40832. keysRotationOffsetDecr: number[];
  40833. /**
  40834. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40835. */
  40836. keysRotationOffsetModifierAlt: boolean;
  40837. /**
  40838. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40839. */
  40840. keysRotationOffsetModifierCtrl: boolean;
  40841. /**
  40842. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40843. */
  40844. keysRotationOffsetModifierShift: boolean;
  40845. /**
  40846. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40847. */
  40848. keysRadiusIncr: number[];
  40849. /**
  40850. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40851. */
  40852. keysRadiusDecr: number[];
  40853. /**
  40854. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40855. */
  40856. keysRadiusModifierAlt: boolean;
  40857. /**
  40858. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40859. */
  40860. keysRadiusModifierCtrl: boolean;
  40861. /**
  40862. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40863. */
  40864. keysRadiusModifierShift: boolean;
  40865. /**
  40866. * Defines the rate of change of heightOffset.
  40867. */
  40868. heightSensibility: number;
  40869. /**
  40870. * Defines the rate of change of rotationOffset.
  40871. */
  40872. rotationSensibility: number;
  40873. /**
  40874. * Defines the rate of change of radius.
  40875. */
  40876. radiusSensibility: number;
  40877. private _keys;
  40878. private _ctrlPressed;
  40879. private _altPressed;
  40880. private _shiftPressed;
  40881. private _onCanvasBlurObserver;
  40882. private _onKeyboardObserver;
  40883. private _engine;
  40884. private _scene;
  40885. /**
  40886. * Attach the input controls to a specific dom element to get the input from.
  40887. * @param element Defines the element the controls should be listened from
  40888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40889. */
  40890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40891. /**
  40892. * Detach the current controls from the specified dom element.
  40893. * @param element Defines the element to stop listening the inputs from
  40894. */
  40895. detachControl(element: Nullable<HTMLElement>): void;
  40896. /**
  40897. * Update the current camera state depending on the inputs that have been used this frame.
  40898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40899. */
  40900. checkInputs(): void;
  40901. /**
  40902. * Gets the class name of the current input.
  40903. * @returns the class name
  40904. */
  40905. getClassName(): string;
  40906. /**
  40907. * Get the friendly name associated with the input class.
  40908. * @returns the input friendly name
  40909. */
  40910. getSimpleName(): string;
  40911. /**
  40912. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40913. * allow modification of the heightOffset value.
  40914. */
  40915. private _modifierHeightOffset;
  40916. /**
  40917. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40918. * allow modification of the rotationOffset value.
  40919. */
  40920. private _modifierRotationOffset;
  40921. /**
  40922. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40923. * allow modification of the radius value.
  40924. */
  40925. private _modifierRadius;
  40926. }
  40927. }
  40928. declare module BABYLON {
  40929. interface FreeCameraInputsManager {
  40930. /**
  40931. * @hidden
  40932. */
  40933. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40934. /**
  40935. * Add orientation input support to the input manager.
  40936. * @returns the current input manager
  40937. */
  40938. addDeviceOrientation(): FreeCameraInputsManager;
  40939. }
  40940. /**
  40941. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40942. * Screen rotation is taken into account.
  40943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40944. */
  40945. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40946. private _camera;
  40947. private _screenOrientationAngle;
  40948. private _constantTranform;
  40949. private _screenQuaternion;
  40950. private _alpha;
  40951. private _beta;
  40952. private _gamma;
  40953. /**
  40954. * Can be used to detect if a device orientation sensor is available on a device
  40955. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40956. * @returns a promise that will resolve on orientation change
  40957. */
  40958. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40959. /**
  40960. * @hidden
  40961. */
  40962. _onDeviceOrientationChangedObservable: Observable<void>;
  40963. /**
  40964. * Instantiates a new input
  40965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40966. */
  40967. constructor();
  40968. /**
  40969. * Define the camera controlled by the input.
  40970. */
  40971. get camera(): FreeCamera;
  40972. set camera(camera: FreeCamera);
  40973. /**
  40974. * Attach the input controls to a specific dom element to get the input from.
  40975. * @param element Defines the element the controls should be listened from
  40976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40977. */
  40978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40979. private _orientationChanged;
  40980. private _deviceOrientation;
  40981. /**
  40982. * Detach the current controls from the specified dom element.
  40983. * @param element Defines the element to stop listening the inputs from
  40984. */
  40985. detachControl(element: Nullable<HTMLElement>): void;
  40986. /**
  40987. * Update the current camera state depending on the inputs that have been used this frame.
  40988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40989. */
  40990. checkInputs(): void;
  40991. /**
  40992. * Gets the class name of the current intput.
  40993. * @returns the class name
  40994. */
  40995. getClassName(): string;
  40996. /**
  40997. * Get the friendly name associated with the input class.
  40998. * @returns the input friendly name
  40999. */
  41000. getSimpleName(): string;
  41001. }
  41002. }
  41003. declare module BABYLON {
  41004. /**
  41005. * Manage the gamepad inputs to control a free camera.
  41006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41007. */
  41008. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41009. /**
  41010. * Define the camera the input is attached to.
  41011. */
  41012. camera: FreeCamera;
  41013. /**
  41014. * Define the Gamepad controlling the input
  41015. */
  41016. gamepad: Nullable<Gamepad>;
  41017. /**
  41018. * Defines the gamepad rotation sensiblity.
  41019. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41020. */
  41021. gamepadAngularSensibility: number;
  41022. /**
  41023. * Defines the gamepad move sensiblity.
  41024. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41025. */
  41026. gamepadMoveSensibility: number;
  41027. private _yAxisScale;
  41028. /**
  41029. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41030. */
  41031. get invertYAxis(): boolean;
  41032. set invertYAxis(value: boolean);
  41033. private _onGamepadConnectedObserver;
  41034. private _onGamepadDisconnectedObserver;
  41035. private _cameraTransform;
  41036. private _deltaTransform;
  41037. private _vector3;
  41038. private _vector2;
  41039. /**
  41040. * Attach the input controls to a specific dom element to get the input from.
  41041. * @param element Defines the element the controls should be listened from
  41042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41043. */
  41044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41045. /**
  41046. * Detach the current controls from the specified dom element.
  41047. * @param element Defines the element to stop listening the inputs from
  41048. */
  41049. detachControl(element: Nullable<HTMLElement>): void;
  41050. /**
  41051. * Update the current camera state depending on the inputs that have been used this frame.
  41052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41053. */
  41054. checkInputs(): void;
  41055. /**
  41056. * Gets the class name of the current intput.
  41057. * @returns the class name
  41058. */
  41059. getClassName(): string;
  41060. /**
  41061. * Get the friendly name associated with the input class.
  41062. * @returns the input friendly name
  41063. */
  41064. getSimpleName(): string;
  41065. }
  41066. }
  41067. declare module BABYLON {
  41068. /**
  41069. * Defines the potential axis of a Joystick
  41070. */
  41071. export enum JoystickAxis {
  41072. /** X axis */
  41073. X = 0,
  41074. /** Y axis */
  41075. Y = 1,
  41076. /** Z axis */
  41077. Z = 2
  41078. }
  41079. /**
  41080. * Class used to define virtual joystick (used in touch mode)
  41081. */
  41082. export class VirtualJoystick {
  41083. /**
  41084. * Gets or sets a boolean indicating that left and right values must be inverted
  41085. */
  41086. reverseLeftRight: boolean;
  41087. /**
  41088. * Gets or sets a boolean indicating that up and down values must be inverted
  41089. */
  41090. reverseUpDown: boolean;
  41091. /**
  41092. * Gets the offset value for the position (ie. the change of the position value)
  41093. */
  41094. deltaPosition: Vector3;
  41095. /**
  41096. * Gets a boolean indicating if the virtual joystick was pressed
  41097. */
  41098. pressed: boolean;
  41099. /**
  41100. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41101. */
  41102. static Canvas: Nullable<HTMLCanvasElement>;
  41103. private static _globalJoystickIndex;
  41104. private static vjCanvasContext;
  41105. private static vjCanvasWidth;
  41106. private static vjCanvasHeight;
  41107. private static halfWidth;
  41108. private _action;
  41109. private _axisTargetedByLeftAndRight;
  41110. private _axisTargetedByUpAndDown;
  41111. private _joystickSensibility;
  41112. private _inversedSensibility;
  41113. private _joystickPointerID;
  41114. private _joystickColor;
  41115. private _joystickPointerPos;
  41116. private _joystickPreviousPointerPos;
  41117. private _joystickPointerStartPos;
  41118. private _deltaJoystickVector;
  41119. private _leftJoystick;
  41120. private _touches;
  41121. private _onPointerDownHandlerRef;
  41122. private _onPointerMoveHandlerRef;
  41123. private _onPointerUpHandlerRef;
  41124. private _onResize;
  41125. /**
  41126. * Creates a new virtual joystick
  41127. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41128. */
  41129. constructor(leftJoystick?: boolean);
  41130. /**
  41131. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41132. * @param newJoystickSensibility defines the new sensibility
  41133. */
  41134. setJoystickSensibility(newJoystickSensibility: number): void;
  41135. private _onPointerDown;
  41136. private _onPointerMove;
  41137. private _onPointerUp;
  41138. /**
  41139. * Change the color of the virtual joystick
  41140. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41141. */
  41142. setJoystickColor(newColor: string): void;
  41143. /**
  41144. * Defines a callback to call when the joystick is touched
  41145. * @param action defines the callback
  41146. */
  41147. setActionOnTouch(action: () => any): void;
  41148. /**
  41149. * Defines which axis you'd like to control for left & right
  41150. * @param axis defines the axis to use
  41151. */
  41152. setAxisForLeftRight(axis: JoystickAxis): void;
  41153. /**
  41154. * Defines which axis you'd like to control for up & down
  41155. * @param axis defines the axis to use
  41156. */
  41157. setAxisForUpDown(axis: JoystickAxis): void;
  41158. private _drawVirtualJoystick;
  41159. /**
  41160. * Release internal HTML canvas
  41161. */
  41162. releaseCanvas(): void;
  41163. }
  41164. }
  41165. declare module BABYLON {
  41166. interface FreeCameraInputsManager {
  41167. /**
  41168. * Add virtual joystick input support to the input manager.
  41169. * @returns the current input manager
  41170. */
  41171. addVirtualJoystick(): FreeCameraInputsManager;
  41172. }
  41173. /**
  41174. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41176. */
  41177. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41178. /**
  41179. * Defines the camera the input is attached to.
  41180. */
  41181. camera: FreeCamera;
  41182. private _leftjoystick;
  41183. private _rightjoystick;
  41184. /**
  41185. * Gets the left stick of the virtual joystick.
  41186. * @returns The virtual Joystick
  41187. */
  41188. getLeftJoystick(): VirtualJoystick;
  41189. /**
  41190. * Gets the right stick of the virtual joystick.
  41191. * @returns The virtual Joystick
  41192. */
  41193. getRightJoystick(): VirtualJoystick;
  41194. /**
  41195. * Update the current camera state depending on the inputs that have been used this frame.
  41196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41197. */
  41198. checkInputs(): void;
  41199. /**
  41200. * Attach the input controls to a specific dom element to get the input from.
  41201. * @param element Defines the element the controls should be listened from
  41202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41203. */
  41204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41205. /**
  41206. * Detach the current controls from the specified dom element.
  41207. * @param element Defines the element to stop listening the inputs from
  41208. */
  41209. detachControl(element: Nullable<HTMLElement>): void;
  41210. /**
  41211. * Gets the class name of the current intput.
  41212. * @returns the class name
  41213. */
  41214. getClassName(): string;
  41215. /**
  41216. * Get the friendly name associated with the input class.
  41217. * @returns the input friendly name
  41218. */
  41219. getSimpleName(): string;
  41220. }
  41221. }
  41222. declare module BABYLON {
  41223. /**
  41224. * This represents a FPS type of camera controlled by touch.
  41225. * This is like a universal camera minus the Gamepad controls.
  41226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41227. */
  41228. export class TouchCamera extends FreeCamera {
  41229. /**
  41230. * Defines the touch sensibility for rotation.
  41231. * The higher the faster.
  41232. */
  41233. get touchAngularSensibility(): number;
  41234. set touchAngularSensibility(value: number);
  41235. /**
  41236. * Defines the touch sensibility for move.
  41237. * The higher the faster.
  41238. */
  41239. get touchMoveSensibility(): number;
  41240. set touchMoveSensibility(value: number);
  41241. /**
  41242. * Instantiates a new touch camera.
  41243. * This represents a FPS type of camera controlled by touch.
  41244. * This is like a universal camera minus the Gamepad controls.
  41245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41246. * @param name Define the name of the camera in the scene
  41247. * @param position Define the start position of the camera in the scene
  41248. * @param scene Define the scene the camera belongs to
  41249. */
  41250. constructor(name: string, position: Vector3, scene: Scene);
  41251. /**
  41252. * Gets the current object class name.
  41253. * @return the class name
  41254. */
  41255. getClassName(): string;
  41256. /** @hidden */
  41257. _setupInputs(): void;
  41258. }
  41259. }
  41260. declare module BABYLON {
  41261. /**
  41262. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41263. * being tilted forward or back and left or right.
  41264. */
  41265. export class DeviceOrientationCamera extends FreeCamera {
  41266. private _initialQuaternion;
  41267. private _quaternionCache;
  41268. private _tmpDragQuaternion;
  41269. private _disablePointerInputWhenUsingDeviceOrientation;
  41270. /**
  41271. * Creates a new device orientation camera
  41272. * @param name The name of the camera
  41273. * @param position The start position camera
  41274. * @param scene The scene the camera belongs to
  41275. */
  41276. constructor(name: string, position: Vector3, scene: Scene);
  41277. /**
  41278. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41279. */
  41280. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41281. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41282. private _dragFactor;
  41283. /**
  41284. * Enabled turning on the y axis when the orientation sensor is active
  41285. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41286. */
  41287. enableHorizontalDragging(dragFactor?: number): void;
  41288. /**
  41289. * Gets the current instance class name ("DeviceOrientationCamera").
  41290. * This helps avoiding instanceof at run time.
  41291. * @returns the class name
  41292. */
  41293. getClassName(): string;
  41294. /**
  41295. * @hidden
  41296. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41297. */
  41298. _checkInputs(): void;
  41299. /**
  41300. * Reset the camera to its default orientation on the specified axis only.
  41301. * @param axis The axis to reset
  41302. */
  41303. resetToCurrentRotation(axis?: Axis): void;
  41304. }
  41305. }
  41306. declare module BABYLON {
  41307. /**
  41308. * Defines supported buttons for XBox360 compatible gamepads
  41309. */
  41310. export enum Xbox360Button {
  41311. /** A */
  41312. A = 0,
  41313. /** B */
  41314. B = 1,
  41315. /** X */
  41316. X = 2,
  41317. /** Y */
  41318. Y = 3,
  41319. /** Left button */
  41320. LB = 4,
  41321. /** Right button */
  41322. RB = 5,
  41323. /** Back */
  41324. Back = 8,
  41325. /** Start */
  41326. Start = 9,
  41327. /** Left stick */
  41328. LeftStick = 10,
  41329. /** Right stick */
  41330. RightStick = 11
  41331. }
  41332. /** Defines values for XBox360 DPad */
  41333. export enum Xbox360Dpad {
  41334. /** Up */
  41335. Up = 12,
  41336. /** Down */
  41337. Down = 13,
  41338. /** Left */
  41339. Left = 14,
  41340. /** Right */
  41341. Right = 15
  41342. }
  41343. /**
  41344. * Defines a XBox360 gamepad
  41345. */
  41346. export class Xbox360Pad extends Gamepad {
  41347. private _leftTrigger;
  41348. private _rightTrigger;
  41349. private _onlefttriggerchanged;
  41350. private _onrighttriggerchanged;
  41351. private _onbuttondown;
  41352. private _onbuttonup;
  41353. private _ondpaddown;
  41354. private _ondpadup;
  41355. /** Observable raised when a button is pressed */
  41356. onButtonDownObservable: Observable<Xbox360Button>;
  41357. /** Observable raised when a button is released */
  41358. onButtonUpObservable: Observable<Xbox360Button>;
  41359. /** Observable raised when a pad is pressed */
  41360. onPadDownObservable: Observable<Xbox360Dpad>;
  41361. /** Observable raised when a pad is released */
  41362. onPadUpObservable: Observable<Xbox360Dpad>;
  41363. private _buttonA;
  41364. private _buttonB;
  41365. private _buttonX;
  41366. private _buttonY;
  41367. private _buttonBack;
  41368. private _buttonStart;
  41369. private _buttonLB;
  41370. private _buttonRB;
  41371. private _buttonLeftStick;
  41372. private _buttonRightStick;
  41373. private _dPadUp;
  41374. private _dPadDown;
  41375. private _dPadLeft;
  41376. private _dPadRight;
  41377. private _isXboxOnePad;
  41378. /**
  41379. * Creates a new XBox360 gamepad object
  41380. * @param id defines the id of this gamepad
  41381. * @param index defines its index
  41382. * @param gamepad defines the internal HTML gamepad object
  41383. * @param xboxOne defines if it is a XBox One gamepad
  41384. */
  41385. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41386. /**
  41387. * Defines the callback to call when left trigger is pressed
  41388. * @param callback defines the callback to use
  41389. */
  41390. onlefttriggerchanged(callback: (value: number) => void): void;
  41391. /**
  41392. * Defines the callback to call when right trigger is pressed
  41393. * @param callback defines the callback to use
  41394. */
  41395. onrighttriggerchanged(callback: (value: number) => void): void;
  41396. /**
  41397. * Gets the left trigger value
  41398. */
  41399. get leftTrigger(): number;
  41400. /**
  41401. * Sets the left trigger value
  41402. */
  41403. set leftTrigger(newValue: number);
  41404. /**
  41405. * Gets the right trigger value
  41406. */
  41407. get rightTrigger(): number;
  41408. /**
  41409. * Sets the right trigger value
  41410. */
  41411. set rightTrigger(newValue: number);
  41412. /**
  41413. * Defines the callback to call when a button is pressed
  41414. * @param callback defines the callback to use
  41415. */
  41416. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41417. /**
  41418. * Defines the callback to call when a button is released
  41419. * @param callback defines the callback to use
  41420. */
  41421. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41422. /**
  41423. * Defines the callback to call when a pad is pressed
  41424. * @param callback defines the callback to use
  41425. */
  41426. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41427. /**
  41428. * Defines the callback to call when a pad is released
  41429. * @param callback defines the callback to use
  41430. */
  41431. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41432. private _setButtonValue;
  41433. private _setDPadValue;
  41434. /**
  41435. * Gets the value of the `A` button
  41436. */
  41437. get buttonA(): number;
  41438. /**
  41439. * Sets the value of the `A` button
  41440. */
  41441. set buttonA(value: number);
  41442. /**
  41443. * Gets the value of the `B` button
  41444. */
  41445. get buttonB(): number;
  41446. /**
  41447. * Sets the value of the `B` button
  41448. */
  41449. set buttonB(value: number);
  41450. /**
  41451. * Gets the value of the `X` button
  41452. */
  41453. get buttonX(): number;
  41454. /**
  41455. * Sets the value of the `X` button
  41456. */
  41457. set buttonX(value: number);
  41458. /**
  41459. * Gets the value of the `Y` button
  41460. */
  41461. get buttonY(): number;
  41462. /**
  41463. * Sets the value of the `Y` button
  41464. */
  41465. set buttonY(value: number);
  41466. /**
  41467. * Gets the value of the `Start` button
  41468. */
  41469. get buttonStart(): number;
  41470. /**
  41471. * Sets the value of the `Start` button
  41472. */
  41473. set buttonStart(value: number);
  41474. /**
  41475. * Gets the value of the `Back` button
  41476. */
  41477. get buttonBack(): number;
  41478. /**
  41479. * Sets the value of the `Back` button
  41480. */
  41481. set buttonBack(value: number);
  41482. /**
  41483. * Gets the value of the `Left` button
  41484. */
  41485. get buttonLB(): number;
  41486. /**
  41487. * Sets the value of the `Left` button
  41488. */
  41489. set buttonLB(value: number);
  41490. /**
  41491. * Gets the value of the `Right` button
  41492. */
  41493. get buttonRB(): number;
  41494. /**
  41495. * Sets the value of the `Right` button
  41496. */
  41497. set buttonRB(value: number);
  41498. /**
  41499. * Gets the value of the Left joystick
  41500. */
  41501. get buttonLeftStick(): number;
  41502. /**
  41503. * Sets the value of the Left joystick
  41504. */
  41505. set buttonLeftStick(value: number);
  41506. /**
  41507. * Gets the value of the Right joystick
  41508. */
  41509. get buttonRightStick(): number;
  41510. /**
  41511. * Sets the value of the Right joystick
  41512. */
  41513. set buttonRightStick(value: number);
  41514. /**
  41515. * Gets the value of D-pad up
  41516. */
  41517. get dPadUp(): number;
  41518. /**
  41519. * Sets the value of D-pad up
  41520. */
  41521. set dPadUp(value: number);
  41522. /**
  41523. * Gets the value of D-pad down
  41524. */
  41525. get dPadDown(): number;
  41526. /**
  41527. * Sets the value of D-pad down
  41528. */
  41529. set dPadDown(value: number);
  41530. /**
  41531. * Gets the value of D-pad left
  41532. */
  41533. get dPadLeft(): number;
  41534. /**
  41535. * Sets the value of D-pad left
  41536. */
  41537. set dPadLeft(value: number);
  41538. /**
  41539. * Gets the value of D-pad right
  41540. */
  41541. get dPadRight(): number;
  41542. /**
  41543. * Sets the value of D-pad right
  41544. */
  41545. set dPadRight(value: number);
  41546. /**
  41547. * Force the gamepad to synchronize with device values
  41548. */
  41549. update(): void;
  41550. /**
  41551. * Disposes the gamepad
  41552. */
  41553. dispose(): void;
  41554. }
  41555. }
  41556. declare module BABYLON {
  41557. /**
  41558. * Defines supported buttons for DualShock compatible gamepads
  41559. */
  41560. export enum DualShockButton {
  41561. /** Cross */
  41562. Cross = 0,
  41563. /** Circle */
  41564. Circle = 1,
  41565. /** Square */
  41566. Square = 2,
  41567. /** Triangle */
  41568. Triangle = 3,
  41569. /** L1 */
  41570. L1 = 4,
  41571. /** R1 */
  41572. R1 = 5,
  41573. /** Share */
  41574. Share = 8,
  41575. /** Options */
  41576. Options = 9,
  41577. /** Left stick */
  41578. LeftStick = 10,
  41579. /** Right stick */
  41580. RightStick = 11
  41581. }
  41582. /** Defines values for DualShock DPad */
  41583. export enum DualShockDpad {
  41584. /** Up */
  41585. Up = 12,
  41586. /** Down */
  41587. Down = 13,
  41588. /** Left */
  41589. Left = 14,
  41590. /** Right */
  41591. Right = 15
  41592. }
  41593. /**
  41594. * Defines a DualShock gamepad
  41595. */
  41596. export class DualShockPad extends Gamepad {
  41597. private _leftTrigger;
  41598. private _rightTrigger;
  41599. private _onlefttriggerchanged;
  41600. private _onrighttriggerchanged;
  41601. private _onbuttondown;
  41602. private _onbuttonup;
  41603. private _ondpaddown;
  41604. private _ondpadup;
  41605. /** Observable raised when a button is pressed */
  41606. onButtonDownObservable: Observable<DualShockButton>;
  41607. /** Observable raised when a button is released */
  41608. onButtonUpObservable: Observable<DualShockButton>;
  41609. /** Observable raised when a pad is pressed */
  41610. onPadDownObservable: Observable<DualShockDpad>;
  41611. /** Observable raised when a pad is released */
  41612. onPadUpObservable: Observable<DualShockDpad>;
  41613. private _buttonCross;
  41614. private _buttonCircle;
  41615. private _buttonSquare;
  41616. private _buttonTriangle;
  41617. private _buttonShare;
  41618. private _buttonOptions;
  41619. private _buttonL1;
  41620. private _buttonR1;
  41621. private _buttonLeftStick;
  41622. private _buttonRightStick;
  41623. private _dPadUp;
  41624. private _dPadDown;
  41625. private _dPadLeft;
  41626. private _dPadRight;
  41627. /**
  41628. * Creates a new DualShock gamepad object
  41629. * @param id defines the id of this gamepad
  41630. * @param index defines its index
  41631. * @param gamepad defines the internal HTML gamepad object
  41632. */
  41633. constructor(id: string, index: number, gamepad: any);
  41634. /**
  41635. * Defines the callback to call when left trigger is pressed
  41636. * @param callback defines the callback to use
  41637. */
  41638. onlefttriggerchanged(callback: (value: number) => void): void;
  41639. /**
  41640. * Defines the callback to call when right trigger is pressed
  41641. * @param callback defines the callback to use
  41642. */
  41643. onrighttriggerchanged(callback: (value: number) => void): void;
  41644. /**
  41645. * Gets the left trigger value
  41646. */
  41647. get leftTrigger(): number;
  41648. /**
  41649. * Sets the left trigger value
  41650. */
  41651. set leftTrigger(newValue: number);
  41652. /**
  41653. * Gets the right trigger value
  41654. */
  41655. get rightTrigger(): number;
  41656. /**
  41657. * Sets the right trigger value
  41658. */
  41659. set rightTrigger(newValue: number);
  41660. /**
  41661. * Defines the callback to call when a button is pressed
  41662. * @param callback defines the callback to use
  41663. */
  41664. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41665. /**
  41666. * Defines the callback to call when a button is released
  41667. * @param callback defines the callback to use
  41668. */
  41669. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41670. /**
  41671. * Defines the callback to call when a pad is pressed
  41672. * @param callback defines the callback to use
  41673. */
  41674. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41675. /**
  41676. * Defines the callback to call when a pad is released
  41677. * @param callback defines the callback to use
  41678. */
  41679. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41680. private _setButtonValue;
  41681. private _setDPadValue;
  41682. /**
  41683. * Gets the value of the `Cross` button
  41684. */
  41685. get buttonCross(): number;
  41686. /**
  41687. * Sets the value of the `Cross` button
  41688. */
  41689. set buttonCross(value: number);
  41690. /**
  41691. * Gets the value of the `Circle` button
  41692. */
  41693. get buttonCircle(): number;
  41694. /**
  41695. * Sets the value of the `Circle` button
  41696. */
  41697. set buttonCircle(value: number);
  41698. /**
  41699. * Gets the value of the `Square` button
  41700. */
  41701. get buttonSquare(): number;
  41702. /**
  41703. * Sets the value of the `Square` button
  41704. */
  41705. set buttonSquare(value: number);
  41706. /**
  41707. * Gets the value of the `Triangle` button
  41708. */
  41709. get buttonTriangle(): number;
  41710. /**
  41711. * Sets the value of the `Triangle` button
  41712. */
  41713. set buttonTriangle(value: number);
  41714. /**
  41715. * Gets the value of the `Options` button
  41716. */
  41717. get buttonOptions(): number;
  41718. /**
  41719. * Sets the value of the `Options` button
  41720. */
  41721. set buttonOptions(value: number);
  41722. /**
  41723. * Gets the value of the `Share` button
  41724. */
  41725. get buttonShare(): number;
  41726. /**
  41727. * Sets the value of the `Share` button
  41728. */
  41729. set buttonShare(value: number);
  41730. /**
  41731. * Gets the value of the `L1` button
  41732. */
  41733. get buttonL1(): number;
  41734. /**
  41735. * Sets the value of the `L1` button
  41736. */
  41737. set buttonL1(value: number);
  41738. /**
  41739. * Gets the value of the `R1` button
  41740. */
  41741. get buttonR1(): number;
  41742. /**
  41743. * Sets the value of the `R1` button
  41744. */
  41745. set buttonR1(value: number);
  41746. /**
  41747. * Gets the value of the Left joystick
  41748. */
  41749. get buttonLeftStick(): number;
  41750. /**
  41751. * Sets the value of the Left joystick
  41752. */
  41753. set buttonLeftStick(value: number);
  41754. /**
  41755. * Gets the value of the Right joystick
  41756. */
  41757. get buttonRightStick(): number;
  41758. /**
  41759. * Sets the value of the Right joystick
  41760. */
  41761. set buttonRightStick(value: number);
  41762. /**
  41763. * Gets the value of D-pad up
  41764. */
  41765. get dPadUp(): number;
  41766. /**
  41767. * Sets the value of D-pad up
  41768. */
  41769. set dPadUp(value: number);
  41770. /**
  41771. * Gets the value of D-pad down
  41772. */
  41773. get dPadDown(): number;
  41774. /**
  41775. * Sets the value of D-pad down
  41776. */
  41777. set dPadDown(value: number);
  41778. /**
  41779. * Gets the value of D-pad left
  41780. */
  41781. get dPadLeft(): number;
  41782. /**
  41783. * Sets the value of D-pad left
  41784. */
  41785. set dPadLeft(value: number);
  41786. /**
  41787. * Gets the value of D-pad right
  41788. */
  41789. get dPadRight(): number;
  41790. /**
  41791. * Sets the value of D-pad right
  41792. */
  41793. set dPadRight(value: number);
  41794. /**
  41795. * Force the gamepad to synchronize with device values
  41796. */
  41797. update(): void;
  41798. /**
  41799. * Disposes the gamepad
  41800. */
  41801. dispose(): void;
  41802. }
  41803. }
  41804. declare module BABYLON {
  41805. /**
  41806. * Manager for handling gamepads
  41807. */
  41808. export class GamepadManager {
  41809. private _scene?;
  41810. private _babylonGamepads;
  41811. private _oneGamepadConnected;
  41812. /** @hidden */
  41813. _isMonitoring: boolean;
  41814. private _gamepadEventSupported;
  41815. private _gamepadSupport?;
  41816. /**
  41817. * observable to be triggered when the gamepad controller has been connected
  41818. */
  41819. onGamepadConnectedObservable: Observable<Gamepad>;
  41820. /**
  41821. * observable to be triggered when the gamepad controller has been disconnected
  41822. */
  41823. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41824. private _onGamepadConnectedEvent;
  41825. private _onGamepadDisconnectedEvent;
  41826. /**
  41827. * Initializes the gamepad manager
  41828. * @param _scene BabylonJS scene
  41829. */
  41830. constructor(_scene?: Scene | undefined);
  41831. /**
  41832. * The gamepads in the game pad manager
  41833. */
  41834. get gamepads(): Gamepad[];
  41835. /**
  41836. * Get the gamepad controllers based on type
  41837. * @param type The type of gamepad controller
  41838. * @returns Nullable gamepad
  41839. */
  41840. getGamepadByType(type?: number): Nullable<Gamepad>;
  41841. /**
  41842. * Disposes the gamepad manager
  41843. */
  41844. dispose(): void;
  41845. private _addNewGamepad;
  41846. private _startMonitoringGamepads;
  41847. private _stopMonitoringGamepads;
  41848. /** @hidden */
  41849. _checkGamepadsStatus(): void;
  41850. private _updateGamepadObjects;
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. interface Scene {
  41855. /** @hidden */
  41856. _gamepadManager: Nullable<GamepadManager>;
  41857. /**
  41858. * Gets the gamepad manager associated with the scene
  41859. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41860. */
  41861. gamepadManager: GamepadManager;
  41862. }
  41863. /**
  41864. * Interface representing a free camera inputs manager
  41865. */
  41866. interface FreeCameraInputsManager {
  41867. /**
  41868. * Adds gamepad input support to the FreeCameraInputsManager.
  41869. * @returns the FreeCameraInputsManager
  41870. */
  41871. addGamepad(): FreeCameraInputsManager;
  41872. }
  41873. /**
  41874. * Interface representing an arc rotate camera inputs manager
  41875. */
  41876. interface ArcRotateCameraInputsManager {
  41877. /**
  41878. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41879. * @returns the camera inputs manager
  41880. */
  41881. addGamepad(): ArcRotateCameraInputsManager;
  41882. }
  41883. /**
  41884. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41885. */
  41886. export class GamepadSystemSceneComponent implements ISceneComponent {
  41887. /**
  41888. * The component name helpfull to identify the component in the list of scene components.
  41889. */
  41890. readonly name: string;
  41891. /**
  41892. * The scene the component belongs to.
  41893. */
  41894. scene: Scene;
  41895. /**
  41896. * Creates a new instance of the component for the given scene
  41897. * @param scene Defines the scene to register the component in
  41898. */
  41899. constructor(scene: Scene);
  41900. /**
  41901. * Registers the component in a given scene
  41902. */
  41903. register(): void;
  41904. /**
  41905. * Rebuilds the elements related to this component in case of
  41906. * context lost for instance.
  41907. */
  41908. rebuild(): void;
  41909. /**
  41910. * Disposes the component and the associated ressources
  41911. */
  41912. dispose(): void;
  41913. private _beforeCameraUpdate;
  41914. }
  41915. }
  41916. declare module BABYLON {
  41917. /**
  41918. * 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,
  41919. * which still works and will still be found in many Playgrounds.
  41920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41921. */
  41922. export class UniversalCamera extends TouchCamera {
  41923. /**
  41924. * Defines the gamepad rotation sensiblity.
  41925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41926. */
  41927. get gamepadAngularSensibility(): number;
  41928. set gamepadAngularSensibility(value: number);
  41929. /**
  41930. * Defines the gamepad move sensiblity.
  41931. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41932. */
  41933. get gamepadMoveSensibility(): number;
  41934. set gamepadMoveSensibility(value: number);
  41935. /**
  41936. * 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,
  41937. * which still works and will still be found in many Playgrounds.
  41938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41939. * @param name Define the name of the camera in the scene
  41940. * @param position Define the start position of the camera in the scene
  41941. * @param scene Define the scene the camera belongs to
  41942. */
  41943. constructor(name: string, position: Vector3, scene: Scene);
  41944. /**
  41945. * Gets the current object class name.
  41946. * @return the class name
  41947. */
  41948. getClassName(): string;
  41949. }
  41950. }
  41951. declare module BABYLON {
  41952. /**
  41953. * This represents a FPS type of camera. This is only here for back compat purpose.
  41954. * Please use the UniversalCamera instead as both are identical.
  41955. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41956. */
  41957. export class GamepadCamera extends UniversalCamera {
  41958. /**
  41959. * Instantiates a new Gamepad Camera
  41960. * This represents a FPS type of camera. This is only here for back compat purpose.
  41961. * Please use the UniversalCamera instead as both are identical.
  41962. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41963. * @param name Define the name of the camera in the scene
  41964. * @param position Define the start position of the camera in the scene
  41965. * @param scene Define the scene the camera belongs to
  41966. */
  41967. constructor(name: string, position: Vector3, scene: Scene);
  41968. /**
  41969. * Gets the current object class name.
  41970. * @return the class name
  41971. */
  41972. getClassName(): string;
  41973. }
  41974. }
  41975. declare module BABYLON {
  41976. /** @hidden */
  41977. export var passPixelShader: {
  41978. name: string;
  41979. shader: string;
  41980. };
  41981. }
  41982. declare module BABYLON {
  41983. /** @hidden */
  41984. export var passCubePixelShader: {
  41985. name: string;
  41986. shader: string;
  41987. };
  41988. }
  41989. declare module BABYLON {
  41990. /**
  41991. * PassPostProcess which produces an output the same as it's input
  41992. */
  41993. export class PassPostProcess extends PostProcess {
  41994. /**
  41995. * Creates the PassPostProcess
  41996. * @param name The name of the effect.
  41997. * @param options The required width/height ratio to downsize to before computing the render pass.
  41998. * @param camera The camera to apply the render pass to.
  41999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42000. * @param engine The engine which the post process will be applied. (default: current engine)
  42001. * @param reusable If the post process can be reused on the same frame. (default: false)
  42002. * @param textureType The type of texture to be used when performing the post processing.
  42003. * @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)
  42004. */
  42005. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42006. }
  42007. /**
  42008. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42009. */
  42010. export class PassCubePostProcess extends PostProcess {
  42011. private _face;
  42012. /**
  42013. * Gets or sets the cube face to display.
  42014. * * 0 is +X
  42015. * * 1 is -X
  42016. * * 2 is +Y
  42017. * * 3 is -Y
  42018. * * 4 is +Z
  42019. * * 5 is -Z
  42020. */
  42021. get face(): number;
  42022. set face(value: number);
  42023. /**
  42024. * Creates the PassCubePostProcess
  42025. * @param name The name of the effect.
  42026. * @param options The required width/height ratio to downsize to before computing the render pass.
  42027. * @param camera The camera to apply the render pass to.
  42028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42029. * @param engine The engine which the post process will be applied. (default: current engine)
  42030. * @param reusable If the post process can be reused on the same frame. (default: false)
  42031. * @param textureType The type of texture to be used when performing the post processing.
  42032. * @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)
  42033. */
  42034. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42035. }
  42036. }
  42037. declare module BABYLON {
  42038. /** @hidden */
  42039. export var anaglyphPixelShader: {
  42040. name: string;
  42041. shader: string;
  42042. };
  42043. }
  42044. declare module BABYLON {
  42045. /**
  42046. * Postprocess used to generate anaglyphic rendering
  42047. */
  42048. export class AnaglyphPostProcess extends PostProcess {
  42049. private _passedProcess;
  42050. /**
  42051. * Creates a new AnaglyphPostProcess
  42052. * @param name defines postprocess name
  42053. * @param options defines creation options or target ratio scale
  42054. * @param rigCameras defines cameras using this postprocess
  42055. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42056. * @param engine defines hosting engine
  42057. * @param reusable defines if the postprocess will be reused multiple times per frame
  42058. */
  42059. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42060. }
  42061. }
  42062. declare module BABYLON {
  42063. /**
  42064. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42065. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42066. */
  42067. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42068. /**
  42069. * Creates a new AnaglyphArcRotateCamera
  42070. * @param name defines camera name
  42071. * @param alpha defines alpha angle (in radians)
  42072. * @param beta defines beta angle (in radians)
  42073. * @param radius defines radius
  42074. * @param target defines camera target
  42075. * @param interaxialDistance defines distance between each color axis
  42076. * @param scene defines the hosting scene
  42077. */
  42078. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42079. /**
  42080. * Gets camera class name
  42081. * @returns AnaglyphArcRotateCamera
  42082. */
  42083. getClassName(): string;
  42084. }
  42085. }
  42086. declare module BABYLON {
  42087. /**
  42088. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42089. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42090. */
  42091. export class AnaglyphFreeCamera extends FreeCamera {
  42092. /**
  42093. * Creates a new AnaglyphFreeCamera
  42094. * @param name defines camera name
  42095. * @param position defines initial position
  42096. * @param interaxialDistance defines distance between each color axis
  42097. * @param scene defines the hosting scene
  42098. */
  42099. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42100. /**
  42101. * Gets camera class name
  42102. * @returns AnaglyphFreeCamera
  42103. */
  42104. getClassName(): string;
  42105. }
  42106. }
  42107. declare module BABYLON {
  42108. /**
  42109. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42110. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42111. */
  42112. export class AnaglyphGamepadCamera extends GamepadCamera {
  42113. /**
  42114. * Creates a new AnaglyphGamepadCamera
  42115. * @param name defines camera name
  42116. * @param position defines initial position
  42117. * @param interaxialDistance defines distance between each color axis
  42118. * @param scene defines the hosting scene
  42119. */
  42120. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42121. /**
  42122. * Gets camera class name
  42123. * @returns AnaglyphGamepadCamera
  42124. */
  42125. getClassName(): string;
  42126. }
  42127. }
  42128. declare module BABYLON {
  42129. /**
  42130. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42131. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42132. */
  42133. export class AnaglyphUniversalCamera extends UniversalCamera {
  42134. /**
  42135. * Creates a new AnaglyphUniversalCamera
  42136. * @param name defines camera name
  42137. * @param position defines initial position
  42138. * @param interaxialDistance defines distance between each color axis
  42139. * @param scene defines the hosting scene
  42140. */
  42141. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42142. /**
  42143. * Gets camera class name
  42144. * @returns AnaglyphUniversalCamera
  42145. */
  42146. getClassName(): string;
  42147. }
  42148. }
  42149. declare module BABYLON {
  42150. /** @hidden */
  42151. export var stereoscopicInterlacePixelShader: {
  42152. name: string;
  42153. shader: string;
  42154. };
  42155. }
  42156. declare module BABYLON {
  42157. /**
  42158. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42159. */
  42160. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42161. private _stepSize;
  42162. private _passedProcess;
  42163. /**
  42164. * Initializes a StereoscopicInterlacePostProcessI
  42165. * @param name The name of the effect.
  42166. * @param rigCameras The rig cameras to be appled to the post process
  42167. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42168. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42170. * @param engine The engine which the post process will be applied. (default: current engine)
  42171. * @param reusable If the post process can be reused on the same frame. (default: false)
  42172. */
  42173. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42174. }
  42175. /**
  42176. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42177. */
  42178. export class StereoscopicInterlacePostProcess extends PostProcess {
  42179. private _stepSize;
  42180. private _passedProcess;
  42181. /**
  42182. * Initializes a StereoscopicInterlacePostProcess
  42183. * @param name The name of the effect.
  42184. * @param rigCameras The rig cameras to be appled to the post process
  42185. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42187. * @param engine The engine which the post process will be applied. (default: current engine)
  42188. * @param reusable If the post process can be reused on the same frame. (default: false)
  42189. */
  42190. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42191. }
  42192. }
  42193. declare module BABYLON {
  42194. /**
  42195. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42196. * @see http://doc.babylonjs.com/features/cameras
  42197. */
  42198. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42199. /**
  42200. * Creates a new StereoscopicArcRotateCamera
  42201. * @param name defines camera name
  42202. * @param alpha defines alpha angle (in radians)
  42203. * @param beta defines beta angle (in radians)
  42204. * @param radius defines radius
  42205. * @param target defines camera target
  42206. * @param interaxialDistance defines distance between each color axis
  42207. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42208. * @param scene defines the hosting scene
  42209. */
  42210. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42211. /**
  42212. * Gets camera class name
  42213. * @returns StereoscopicArcRotateCamera
  42214. */
  42215. getClassName(): string;
  42216. }
  42217. }
  42218. declare module BABYLON {
  42219. /**
  42220. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42221. * @see http://doc.babylonjs.com/features/cameras
  42222. */
  42223. export class StereoscopicFreeCamera extends FreeCamera {
  42224. /**
  42225. * Creates a new StereoscopicFreeCamera
  42226. * @param name defines camera name
  42227. * @param position defines initial position
  42228. * @param interaxialDistance defines distance between each color axis
  42229. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42230. * @param scene defines the hosting scene
  42231. */
  42232. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42233. /**
  42234. * Gets camera class name
  42235. * @returns StereoscopicFreeCamera
  42236. */
  42237. getClassName(): string;
  42238. }
  42239. }
  42240. declare module BABYLON {
  42241. /**
  42242. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42243. * @see http://doc.babylonjs.com/features/cameras
  42244. */
  42245. export class StereoscopicGamepadCamera extends GamepadCamera {
  42246. /**
  42247. * Creates a new StereoscopicGamepadCamera
  42248. * @param name defines camera name
  42249. * @param position defines initial position
  42250. * @param interaxialDistance defines distance between each color axis
  42251. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42252. * @param scene defines the hosting scene
  42253. */
  42254. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42255. /**
  42256. * Gets camera class name
  42257. * @returns StereoscopicGamepadCamera
  42258. */
  42259. getClassName(): string;
  42260. }
  42261. }
  42262. declare module BABYLON {
  42263. /**
  42264. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42265. * @see http://doc.babylonjs.com/features/cameras
  42266. */
  42267. export class StereoscopicUniversalCamera extends UniversalCamera {
  42268. /**
  42269. * Creates a new StereoscopicUniversalCamera
  42270. * @param name defines camera name
  42271. * @param position defines initial position
  42272. * @param interaxialDistance defines distance between each color axis
  42273. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42274. * @param scene defines the hosting scene
  42275. */
  42276. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42277. /**
  42278. * Gets camera class name
  42279. * @returns StereoscopicUniversalCamera
  42280. */
  42281. getClassName(): string;
  42282. }
  42283. }
  42284. declare module BABYLON {
  42285. /**
  42286. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42287. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42288. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42289. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42290. */
  42291. export class VirtualJoysticksCamera extends FreeCamera {
  42292. /**
  42293. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42294. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42295. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42296. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42297. * @param name Define the name of the camera in the scene
  42298. * @param position Define the start position of the camera in the scene
  42299. * @param scene Define the scene the camera belongs to
  42300. */
  42301. constructor(name: string, position: Vector3, scene: Scene);
  42302. /**
  42303. * Gets the current object class name.
  42304. * @return the class name
  42305. */
  42306. getClassName(): string;
  42307. }
  42308. }
  42309. declare module BABYLON {
  42310. /**
  42311. * This represents all the required metrics to create a VR camera.
  42312. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42313. */
  42314. export class VRCameraMetrics {
  42315. /**
  42316. * Define the horizontal resolution off the screen.
  42317. */
  42318. hResolution: number;
  42319. /**
  42320. * Define the vertical resolution off the screen.
  42321. */
  42322. vResolution: number;
  42323. /**
  42324. * Define the horizontal screen size.
  42325. */
  42326. hScreenSize: number;
  42327. /**
  42328. * Define the vertical screen size.
  42329. */
  42330. vScreenSize: number;
  42331. /**
  42332. * Define the vertical screen center position.
  42333. */
  42334. vScreenCenter: number;
  42335. /**
  42336. * Define the distance of the eyes to the screen.
  42337. */
  42338. eyeToScreenDistance: number;
  42339. /**
  42340. * Define the distance between both lenses
  42341. */
  42342. lensSeparationDistance: number;
  42343. /**
  42344. * Define the distance between both viewer's eyes.
  42345. */
  42346. interpupillaryDistance: number;
  42347. /**
  42348. * Define the distortion factor of the VR postprocess.
  42349. * Please, touch with care.
  42350. */
  42351. distortionK: number[];
  42352. /**
  42353. * Define the chromatic aberration correction factors for the VR post process.
  42354. */
  42355. chromaAbCorrection: number[];
  42356. /**
  42357. * Define the scale factor of the post process.
  42358. * The smaller the better but the slower.
  42359. */
  42360. postProcessScaleFactor: number;
  42361. /**
  42362. * Define an offset for the lens center.
  42363. */
  42364. lensCenterOffset: number;
  42365. /**
  42366. * Define if the current vr camera should compensate the distortion of the lense or not.
  42367. */
  42368. compensateDistortion: boolean;
  42369. /**
  42370. * Defines if multiview should be enabled when rendering (Default: false)
  42371. */
  42372. multiviewEnabled: boolean;
  42373. /**
  42374. * Gets the rendering aspect ratio based on the provided resolutions.
  42375. */
  42376. get aspectRatio(): number;
  42377. /**
  42378. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42379. */
  42380. get aspectRatioFov(): number;
  42381. /**
  42382. * @hidden
  42383. */
  42384. get leftHMatrix(): Matrix;
  42385. /**
  42386. * @hidden
  42387. */
  42388. get rightHMatrix(): Matrix;
  42389. /**
  42390. * @hidden
  42391. */
  42392. get leftPreViewMatrix(): Matrix;
  42393. /**
  42394. * @hidden
  42395. */
  42396. get rightPreViewMatrix(): Matrix;
  42397. /**
  42398. * Get the default VRMetrics based on the most generic setup.
  42399. * @returns the default vr metrics
  42400. */
  42401. static GetDefault(): VRCameraMetrics;
  42402. }
  42403. }
  42404. declare module BABYLON {
  42405. /** @hidden */
  42406. export var vrDistortionCorrectionPixelShader: {
  42407. name: string;
  42408. shader: string;
  42409. };
  42410. }
  42411. declare module BABYLON {
  42412. /**
  42413. * VRDistortionCorrectionPostProcess used for mobile VR
  42414. */
  42415. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42416. private _isRightEye;
  42417. private _distortionFactors;
  42418. private _postProcessScaleFactor;
  42419. private _lensCenterOffset;
  42420. private _scaleIn;
  42421. private _scaleFactor;
  42422. private _lensCenter;
  42423. /**
  42424. * Initializes the VRDistortionCorrectionPostProcess
  42425. * @param name The name of the effect.
  42426. * @param camera The camera to apply the render pass to.
  42427. * @param isRightEye If this is for the right eye distortion
  42428. * @param vrMetrics All the required metrics for the VR camera
  42429. */
  42430. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42431. }
  42432. }
  42433. declare module BABYLON {
  42434. /**
  42435. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42436. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42437. */
  42438. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42439. /**
  42440. * Creates a new VRDeviceOrientationArcRotateCamera
  42441. * @param name defines camera name
  42442. * @param alpha defines the camera rotation along the logitudinal axis
  42443. * @param beta defines the camera rotation along the latitudinal axis
  42444. * @param radius defines the camera distance from its target
  42445. * @param target defines the camera target
  42446. * @param scene defines the scene the camera belongs to
  42447. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42448. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42449. */
  42450. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42451. /**
  42452. * Gets camera class name
  42453. * @returns VRDeviceOrientationArcRotateCamera
  42454. */
  42455. getClassName(): string;
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Camera used to simulate VR rendering (based on FreeCamera)
  42461. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42462. */
  42463. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42464. /**
  42465. * Creates a new VRDeviceOrientationFreeCamera
  42466. * @param name defines camera name
  42467. * @param position defines the start position of the camera
  42468. * @param scene defines the scene the camera belongs to
  42469. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42470. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42471. */
  42472. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42473. /**
  42474. * Gets camera class name
  42475. * @returns VRDeviceOrientationFreeCamera
  42476. */
  42477. getClassName(): string;
  42478. }
  42479. }
  42480. declare module BABYLON {
  42481. /**
  42482. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42483. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42484. */
  42485. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42486. /**
  42487. * Creates a new VRDeviceOrientationGamepadCamera
  42488. * @param name defines camera name
  42489. * @param position defines the start position of the camera
  42490. * @param scene defines the scene the camera belongs to
  42491. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42492. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42493. */
  42494. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42495. /**
  42496. * Gets camera class name
  42497. * @returns VRDeviceOrientationGamepadCamera
  42498. */
  42499. getClassName(): string;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /** @hidden */
  42504. export var imageProcessingPixelShader: {
  42505. name: string;
  42506. shader: string;
  42507. };
  42508. }
  42509. declare module BABYLON {
  42510. /**
  42511. * ImageProcessingPostProcess
  42512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42513. */
  42514. export class ImageProcessingPostProcess extends PostProcess {
  42515. /**
  42516. * Default configuration related to image processing available in the PBR Material.
  42517. */
  42518. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42519. /**
  42520. * Gets the image processing configuration used either in this material.
  42521. */
  42522. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42523. /**
  42524. * Sets the Default image processing configuration used either in the this material.
  42525. *
  42526. * If sets to null, the scene one is in use.
  42527. */
  42528. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42529. /**
  42530. * Keep track of the image processing observer to allow dispose and replace.
  42531. */
  42532. private _imageProcessingObserver;
  42533. /**
  42534. * Attaches a new image processing configuration to the PBR Material.
  42535. * @param configuration
  42536. */
  42537. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42538. /**
  42539. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42540. */
  42541. get colorCurves(): Nullable<ColorCurves>;
  42542. /**
  42543. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42544. */
  42545. set colorCurves(value: Nullable<ColorCurves>);
  42546. /**
  42547. * Gets wether the color curves effect is enabled.
  42548. */
  42549. get colorCurvesEnabled(): boolean;
  42550. /**
  42551. * Sets wether the color curves effect is enabled.
  42552. */
  42553. set colorCurvesEnabled(value: boolean);
  42554. /**
  42555. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42556. */
  42557. get colorGradingTexture(): Nullable<BaseTexture>;
  42558. /**
  42559. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42560. */
  42561. set colorGradingTexture(value: Nullable<BaseTexture>);
  42562. /**
  42563. * Gets wether the color grading effect is enabled.
  42564. */
  42565. get colorGradingEnabled(): boolean;
  42566. /**
  42567. * Gets wether the color grading effect is enabled.
  42568. */
  42569. set colorGradingEnabled(value: boolean);
  42570. /**
  42571. * Gets exposure used in the effect.
  42572. */
  42573. get exposure(): number;
  42574. /**
  42575. * Sets exposure used in the effect.
  42576. */
  42577. set exposure(value: number);
  42578. /**
  42579. * Gets wether tonemapping is enabled or not.
  42580. */
  42581. get toneMappingEnabled(): boolean;
  42582. /**
  42583. * Sets wether tonemapping is enabled or not
  42584. */
  42585. set toneMappingEnabled(value: boolean);
  42586. /**
  42587. * Gets the type of tone mapping effect.
  42588. */
  42589. get toneMappingType(): number;
  42590. /**
  42591. * Sets the type of tone mapping effect.
  42592. */
  42593. set toneMappingType(value: number);
  42594. /**
  42595. * Gets contrast used in the effect.
  42596. */
  42597. get contrast(): number;
  42598. /**
  42599. * Sets contrast used in the effect.
  42600. */
  42601. set contrast(value: number);
  42602. /**
  42603. * Gets Vignette stretch size.
  42604. */
  42605. get vignetteStretch(): number;
  42606. /**
  42607. * Sets Vignette stretch size.
  42608. */
  42609. set vignetteStretch(value: number);
  42610. /**
  42611. * Gets Vignette centre X Offset.
  42612. */
  42613. get vignetteCentreX(): number;
  42614. /**
  42615. * Sets Vignette centre X Offset.
  42616. */
  42617. set vignetteCentreX(value: number);
  42618. /**
  42619. * Gets Vignette centre Y Offset.
  42620. */
  42621. get vignetteCentreY(): number;
  42622. /**
  42623. * Sets Vignette centre Y Offset.
  42624. */
  42625. set vignetteCentreY(value: number);
  42626. /**
  42627. * Gets Vignette weight or intensity of the vignette effect.
  42628. */
  42629. get vignetteWeight(): number;
  42630. /**
  42631. * Sets Vignette weight or intensity of the vignette effect.
  42632. */
  42633. set vignetteWeight(value: number);
  42634. /**
  42635. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42636. * if vignetteEnabled is set to true.
  42637. */
  42638. get vignetteColor(): Color4;
  42639. /**
  42640. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42641. * if vignetteEnabled is set to true.
  42642. */
  42643. set vignetteColor(value: Color4);
  42644. /**
  42645. * Gets Camera field of view used by the Vignette effect.
  42646. */
  42647. get vignetteCameraFov(): number;
  42648. /**
  42649. * Sets Camera field of view used by the Vignette effect.
  42650. */
  42651. set vignetteCameraFov(value: number);
  42652. /**
  42653. * Gets the vignette blend mode allowing different kind of effect.
  42654. */
  42655. get vignetteBlendMode(): number;
  42656. /**
  42657. * Sets the vignette blend mode allowing different kind of effect.
  42658. */
  42659. set vignetteBlendMode(value: number);
  42660. /**
  42661. * Gets wether the vignette effect is enabled.
  42662. */
  42663. get vignetteEnabled(): boolean;
  42664. /**
  42665. * Sets wether the vignette effect is enabled.
  42666. */
  42667. set vignetteEnabled(value: boolean);
  42668. private _fromLinearSpace;
  42669. /**
  42670. * Gets wether the input of the processing is in Gamma or Linear Space.
  42671. */
  42672. get fromLinearSpace(): boolean;
  42673. /**
  42674. * Sets wether the input of the processing is in Gamma or Linear Space.
  42675. */
  42676. set fromLinearSpace(value: boolean);
  42677. /**
  42678. * Defines cache preventing GC.
  42679. */
  42680. private _defines;
  42681. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42682. /**
  42683. * "ImageProcessingPostProcess"
  42684. * @returns "ImageProcessingPostProcess"
  42685. */
  42686. getClassName(): string;
  42687. protected _updateParameters(): void;
  42688. dispose(camera?: Camera): void;
  42689. }
  42690. }
  42691. declare module BABYLON {
  42692. /**
  42693. * Class containing static functions to help procedurally build meshes
  42694. */
  42695. export class GroundBuilder {
  42696. /**
  42697. * Creates a ground mesh
  42698. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42699. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42701. * @param name defines the name of the mesh
  42702. * @param options defines the options used to create the mesh
  42703. * @param scene defines the hosting scene
  42704. * @returns the ground mesh
  42705. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42706. */
  42707. static CreateGround(name: string, options: {
  42708. width?: number;
  42709. height?: number;
  42710. subdivisions?: number;
  42711. subdivisionsX?: number;
  42712. subdivisionsY?: number;
  42713. updatable?: boolean;
  42714. }, scene: any): Mesh;
  42715. /**
  42716. * Creates a tiled ground mesh
  42717. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42718. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42719. * * 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
  42720. * * 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
  42721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42722. * @param name defines the name of the mesh
  42723. * @param options defines the options used to create the mesh
  42724. * @param scene defines the hosting scene
  42725. * @returns the tiled ground mesh
  42726. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42727. */
  42728. static CreateTiledGround(name: string, options: {
  42729. xmin: number;
  42730. zmin: number;
  42731. xmax: number;
  42732. zmax: number;
  42733. subdivisions?: {
  42734. w: number;
  42735. h: number;
  42736. };
  42737. precision?: {
  42738. w: number;
  42739. h: number;
  42740. };
  42741. updatable?: boolean;
  42742. }, scene?: Nullable<Scene>): Mesh;
  42743. /**
  42744. * Creates a ground mesh from a height map
  42745. * * The parameter `url` sets the URL of the height map image resource.
  42746. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42747. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42748. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42749. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42750. * * 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.
  42751. * * 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).
  42752. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42754. * @param name defines the name of the mesh
  42755. * @param url defines the url to the height map
  42756. * @param options defines the options used to create the mesh
  42757. * @param scene defines the hosting scene
  42758. * @returns the ground mesh
  42759. * @see https://doc.babylonjs.com/babylon101/height_map
  42760. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42761. */
  42762. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42763. width?: number;
  42764. height?: number;
  42765. subdivisions?: number;
  42766. minHeight?: number;
  42767. maxHeight?: number;
  42768. colorFilter?: Color3;
  42769. alphaFilter?: number;
  42770. updatable?: boolean;
  42771. onReady?: (mesh: GroundMesh) => void;
  42772. }, scene?: Nullable<Scene>): GroundMesh;
  42773. }
  42774. }
  42775. declare module BABYLON {
  42776. /**
  42777. * Class containing static functions to help procedurally build meshes
  42778. */
  42779. export class TorusBuilder {
  42780. /**
  42781. * Creates a torus mesh
  42782. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42783. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42784. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42786. * * 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
  42787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42788. * @param name defines the name of the mesh
  42789. * @param options defines the options used to create the mesh
  42790. * @param scene defines the hosting scene
  42791. * @returns the torus mesh
  42792. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42793. */
  42794. static CreateTorus(name: string, options: {
  42795. diameter?: number;
  42796. thickness?: number;
  42797. tessellation?: number;
  42798. updatable?: boolean;
  42799. sideOrientation?: number;
  42800. frontUVs?: Vector4;
  42801. backUVs?: Vector4;
  42802. }, scene: any): Mesh;
  42803. }
  42804. }
  42805. declare module BABYLON {
  42806. /**
  42807. * Class containing static functions to help procedurally build meshes
  42808. */
  42809. export class CylinderBuilder {
  42810. /**
  42811. * Creates a cylinder or a cone mesh
  42812. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42813. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42814. * * 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.
  42815. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42816. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42817. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42818. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42819. * * 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).
  42820. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42821. * * 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).
  42822. * * 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
  42823. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42824. * * 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
  42825. * * 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.
  42826. * * If `enclose` is false, a ring surface is one element.
  42827. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42828. * * 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
  42829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42830. * * 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
  42831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42832. * @param name defines the name of the mesh
  42833. * @param options defines the options used to create the mesh
  42834. * @param scene defines the hosting scene
  42835. * @returns the cylinder mesh
  42836. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42837. */
  42838. static CreateCylinder(name: string, options: {
  42839. height?: number;
  42840. diameterTop?: number;
  42841. diameterBottom?: number;
  42842. diameter?: number;
  42843. tessellation?: number;
  42844. subdivisions?: number;
  42845. arc?: number;
  42846. faceColors?: Color4[];
  42847. faceUV?: Vector4[];
  42848. updatable?: boolean;
  42849. hasRings?: boolean;
  42850. enclose?: boolean;
  42851. cap?: number;
  42852. sideOrientation?: number;
  42853. frontUVs?: Vector4;
  42854. backUVs?: Vector4;
  42855. }, scene: any): Mesh;
  42856. }
  42857. }
  42858. declare module BABYLON {
  42859. /**
  42860. * States of the webXR experience
  42861. */
  42862. export enum WebXRState {
  42863. /**
  42864. * Transitioning to being in XR mode
  42865. */
  42866. ENTERING_XR = 0,
  42867. /**
  42868. * Transitioning to non XR mode
  42869. */
  42870. EXITING_XR = 1,
  42871. /**
  42872. * In XR mode and presenting
  42873. */
  42874. IN_XR = 2,
  42875. /**
  42876. * Not entered XR mode
  42877. */
  42878. NOT_IN_XR = 3
  42879. }
  42880. /**
  42881. * Abstraction of the XR render target
  42882. */
  42883. export interface WebXRRenderTarget extends IDisposable {
  42884. /**
  42885. * xrpresent context of the canvas which can be used to display/mirror xr content
  42886. */
  42887. canvasContext: WebGLRenderingContext;
  42888. /**
  42889. * xr layer for the canvas
  42890. */
  42891. xrLayer: Nullable<XRWebGLLayer>;
  42892. /**
  42893. * Initializes the xr layer for the session
  42894. * @param xrSession xr session
  42895. * @returns a promise that will resolve once the XR Layer has been created
  42896. */
  42897. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42898. }
  42899. }
  42900. declare module BABYLON {
  42901. /**
  42902. * COnfiguration object for WebXR output canvas
  42903. */
  42904. export class WebXRManagedOutputCanvasOptions {
  42905. /**
  42906. * An optional canvas in case you wish to create it yourself and provide it here.
  42907. * If not provided, a new canvas will be created
  42908. */
  42909. canvasElement?: HTMLCanvasElement;
  42910. /**
  42911. * Options for this XR Layer output
  42912. */
  42913. canvasOptions?: XRWebGLLayerOptions;
  42914. /**
  42915. * CSS styling for a newly created canvas (if not provided)
  42916. */
  42917. newCanvasCssStyle?: string;
  42918. /**
  42919. * Get the default values of the configuration object
  42920. * @returns default values of this configuration object
  42921. */
  42922. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42923. }
  42924. /**
  42925. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42926. */
  42927. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42928. private _options;
  42929. private _canvas;
  42930. private _engine;
  42931. /**
  42932. * Rendering context of the canvas which can be used to display/mirror xr content
  42933. */
  42934. canvasContext: WebGLRenderingContext;
  42935. /**
  42936. * xr layer for the canvas
  42937. */
  42938. xrLayer: Nullable<XRWebGLLayer>;
  42939. /**
  42940. * Initializes the canvas to be added/removed upon entering/exiting xr
  42941. * @param _xrSessionManager The XR Session manager
  42942. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42943. */
  42944. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42945. /**
  42946. * Disposes of the object
  42947. */
  42948. dispose(): void;
  42949. /**
  42950. * Initializes the xr layer for the session
  42951. * @param xrSession xr session
  42952. * @returns a promise that will resolve once the XR Layer has been created
  42953. */
  42954. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42955. private _addCanvas;
  42956. private _removeCanvas;
  42957. private _setManagedOutputCanvas;
  42958. }
  42959. }
  42960. declare module BABYLON {
  42961. /**
  42962. * Manages an XRSession to work with Babylon's engine
  42963. * @see https://doc.babylonjs.com/how_to/webxr
  42964. */
  42965. export class WebXRSessionManager implements IDisposable {
  42966. /** The scene which the session should be created for */
  42967. scene: Scene;
  42968. private _referenceSpace;
  42969. private _rttProvider;
  42970. private _sessionEnded;
  42971. private _xrNavigator;
  42972. private baseLayer;
  42973. /**
  42974. * The base reference space from which the session started. good if you want to reset your
  42975. * reference space
  42976. */
  42977. baseReferenceSpace: XRReferenceSpace;
  42978. /**
  42979. * Current XR frame
  42980. */
  42981. currentFrame: Nullable<XRFrame>;
  42982. /** WebXR timestamp updated every frame */
  42983. currentTimestamp: number;
  42984. /**
  42985. * Used just in case of a failure to initialize an immersive session.
  42986. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42987. */
  42988. defaultHeightCompensation: number;
  42989. /**
  42990. * Fires every time a new xrFrame arrives which can be used to update the camera
  42991. */
  42992. onXRFrameObservable: Observable<XRFrame>;
  42993. /**
  42994. * Fires when the reference space changed
  42995. */
  42996. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42997. /**
  42998. * Fires when the xr session is ended either by the device or manually done
  42999. */
  43000. onXRSessionEnded: Observable<any>;
  43001. /**
  43002. * Fires when the xr session is ended either by the device or manually done
  43003. */
  43004. onXRSessionInit: Observable<XRSession>;
  43005. /**
  43006. * Underlying xr session
  43007. */
  43008. session: XRSession;
  43009. /**
  43010. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43011. * or get the offset the player is currently at.
  43012. */
  43013. viewerReferenceSpace: XRReferenceSpace;
  43014. /**
  43015. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43016. * @param scene The scene which the session should be created for
  43017. */
  43018. constructor(
  43019. /** The scene which the session should be created for */
  43020. scene: Scene);
  43021. /**
  43022. * The current reference space used in this session. This reference space can constantly change!
  43023. * It is mainly used to offset the camera's position.
  43024. */
  43025. get referenceSpace(): XRReferenceSpace;
  43026. /**
  43027. * Set a new reference space and triggers the observable
  43028. */
  43029. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43030. /**
  43031. * Disposes of the session manager
  43032. */
  43033. dispose(): void;
  43034. /**
  43035. * Stops the xrSession and restores the render loop
  43036. * @returns Promise which resolves after it exits XR
  43037. */
  43038. exitXRAsync(): Promise<void>;
  43039. /**
  43040. * Gets the correct render target texture to be rendered this frame for this eye
  43041. * @param eye the eye for which to get the render target
  43042. * @returns the render target for the specified eye
  43043. */
  43044. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43045. /**
  43046. * Creates a WebXRRenderTarget object for the XR session
  43047. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43048. * @param options optional options to provide when creating a new render target
  43049. * @returns a WebXR render target to which the session can render
  43050. */
  43051. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43052. /**
  43053. * Initializes the manager
  43054. * After initialization enterXR can be called to start an XR session
  43055. * @returns Promise which resolves after it is initialized
  43056. */
  43057. initializeAsync(): Promise<void>;
  43058. /**
  43059. * Initializes an xr session
  43060. * @param xrSessionMode mode to initialize
  43061. * @param xrSessionInit defines optional and required values to pass to the session builder
  43062. * @returns a promise which will resolve once the session has been initialized
  43063. */
  43064. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43065. /**
  43066. * Checks if a session would be supported for the creation options specified
  43067. * @param sessionMode session mode to check if supported eg. immersive-vr
  43068. * @returns A Promise that resolves to true if supported and false if not
  43069. */
  43070. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43071. /**
  43072. * Resets the reference space to the one started the session
  43073. */
  43074. resetReferenceSpace(): void;
  43075. /**
  43076. * Starts rendering to the xr layer
  43077. */
  43078. runXRRenderLoop(): void;
  43079. /**
  43080. * Sets the reference space on the xr session
  43081. * @param referenceSpaceType space to set
  43082. * @returns a promise that will resolve once the reference space has been set
  43083. */
  43084. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43085. /**
  43086. * Updates the render state of the session
  43087. * @param state state to set
  43088. * @returns a promise that resolves once the render state has been updated
  43089. */
  43090. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43091. /**
  43092. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43093. * @param sessionMode defines the session to test
  43094. * @returns a promise with boolean as final value
  43095. */
  43096. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43097. private _createRenderTargetTexture;
  43098. }
  43099. }
  43100. declare module BABYLON {
  43101. /**
  43102. * WebXR Camera which holds the views for the xrSession
  43103. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43104. */
  43105. export class WebXRCamera extends FreeCamera {
  43106. private _xrSessionManager;
  43107. private _firstFrame;
  43108. private _referenceQuaternion;
  43109. private _referencedPosition;
  43110. private _xrInvPositionCache;
  43111. private _xrInvQuaternionCache;
  43112. /**
  43113. * Should position compensation execute on first frame.
  43114. * This is used when copying the position from a native (non XR) camera
  43115. */
  43116. compensateOnFirstFrame: boolean;
  43117. /**
  43118. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43119. * @param name the name of the camera
  43120. * @param scene the scene to add the camera to
  43121. * @param _xrSessionManager a constructed xr session manager
  43122. */
  43123. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43124. /**
  43125. * Return the user's height, unrelated to the current ground.
  43126. * This will be the y position of this camera, when ground level is 0.
  43127. */
  43128. get realWorldHeight(): number;
  43129. /** @hidden */
  43130. _updateForDualEyeDebugging(): void;
  43131. /**
  43132. * Sets this camera's transformation based on a non-vr camera
  43133. * @param otherCamera the non-vr camera to copy the transformation from
  43134. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43135. */
  43136. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43137. /**
  43138. * Gets the current instance class name ("WebXRCamera").
  43139. * @returns the class name
  43140. */
  43141. getClassName(): string;
  43142. private _updateFromXRSession;
  43143. private _updateNumberOfRigCameras;
  43144. private _updateReferenceSpace;
  43145. private _updateReferenceSpaceOffset;
  43146. }
  43147. }
  43148. declare module BABYLON {
  43149. /**
  43150. * Defining the interface required for a (webxr) feature
  43151. */
  43152. export interface IWebXRFeature extends IDisposable {
  43153. /**
  43154. * Is this feature attached
  43155. */
  43156. attached: boolean;
  43157. /**
  43158. * Should auto-attach be disabled?
  43159. */
  43160. disableAutoAttach: boolean;
  43161. /**
  43162. * Attach the feature to the session
  43163. * Will usually be called by the features manager
  43164. *
  43165. * @param force should attachment be forced (even when already attached)
  43166. * @returns true if successful.
  43167. */
  43168. attach(force?: boolean): boolean;
  43169. /**
  43170. * Detach the feature from the session
  43171. * Will usually be called by the features manager
  43172. *
  43173. * @returns true if successful.
  43174. */
  43175. detach(): boolean;
  43176. }
  43177. /**
  43178. * A list of the currently available features without referencing them
  43179. */
  43180. export class WebXRFeatureName {
  43181. /**
  43182. * The name of the anchor system feature
  43183. */
  43184. static ANCHOR_SYSTEM: string;
  43185. /**
  43186. * The name of the background remover feature
  43187. */
  43188. static BACKGROUND_REMOVER: string;
  43189. /**
  43190. * The name of the hit test feature
  43191. */
  43192. static HIT_TEST: string;
  43193. /**
  43194. * physics impostors for xr controllers feature
  43195. */
  43196. static PHYSICS_CONTROLLERS: string;
  43197. /**
  43198. * The name of the plane detection feature
  43199. */
  43200. static PLANE_DETECTION: string;
  43201. /**
  43202. * The name of the pointer selection feature
  43203. */
  43204. static POINTER_SELECTION: string;
  43205. /**
  43206. * The name of the teleportation feature
  43207. */
  43208. static TELEPORTATION: string;
  43209. }
  43210. /**
  43211. * Defining the constructor of a feature. Used to register the modules.
  43212. */
  43213. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43214. /**
  43215. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43216. * It is mainly used in AR sessions.
  43217. *
  43218. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43219. */
  43220. export class WebXRFeaturesManager implements IDisposable {
  43221. private _xrSessionManager;
  43222. private static readonly _AvailableFeatures;
  43223. private _features;
  43224. /**
  43225. * constructs a new features manages.
  43226. *
  43227. * @param _xrSessionManager an instance of WebXRSessionManager
  43228. */
  43229. constructor(_xrSessionManager: WebXRSessionManager);
  43230. /**
  43231. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43232. * Mainly used internally.
  43233. *
  43234. * @param featureName the name of the feature to register
  43235. * @param constructorFunction the function used to construct the module
  43236. * @param version the (babylon) version of the module
  43237. * @param stable is that a stable version of this module
  43238. */
  43239. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43240. /**
  43241. * Returns a constructor of a specific feature.
  43242. *
  43243. * @param featureName the name of the feature to construct
  43244. * @param version the version of the feature to load
  43245. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43246. * @param options optional options provided to the module.
  43247. * @returns a function that, when called, will return a new instance of this feature
  43248. */
  43249. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43250. /**
  43251. * Can be used to return the list of features currently registered
  43252. *
  43253. * @returns an Array of available features
  43254. */
  43255. static GetAvailableFeatures(): string[];
  43256. /**
  43257. * Gets the versions available for a specific feature
  43258. * @param featureName the name of the feature
  43259. * @returns an array with the available versions
  43260. */
  43261. static GetAvailableVersions(featureName: string): string[];
  43262. /**
  43263. * Return the latest unstable version of this feature
  43264. * @param featureName the name of the feature to search
  43265. * @returns the version number. if not found will return -1
  43266. */
  43267. static GetLatestVersionOfFeature(featureName: string): number;
  43268. /**
  43269. * Return the latest stable version of this feature
  43270. * @param featureName the name of the feature to search
  43271. * @returns the version number. if not found will return -1
  43272. */
  43273. static GetStableVersionOfFeature(featureName: string): number;
  43274. /**
  43275. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43276. * Can be used during a session to start a feature
  43277. * @param featureName the name of feature to attach
  43278. */
  43279. attachFeature(featureName: string): void;
  43280. /**
  43281. * Can be used inside a session or when the session ends to detach a specific feature
  43282. * @param featureName the name of the feature to detach
  43283. */
  43284. detachFeature(featureName: string): void;
  43285. /**
  43286. * Used to disable an already-enabled feature
  43287. * The feature will be disposed and will be recreated once enabled.
  43288. * @param featureName the feature to disable
  43289. * @returns true if disable was successful
  43290. */
  43291. disableFeature(featureName: string | {
  43292. Name: string;
  43293. }): boolean;
  43294. /**
  43295. * dispose this features manager
  43296. */
  43297. dispose(): void;
  43298. /**
  43299. * 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.
  43300. * 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.
  43301. *
  43302. * @param featureName the name of the feature to load or the class of the feature
  43303. * @param version optional version to load. if not provided the latest version will be enabled
  43304. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43305. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43306. * @returns a new constructed feature or throws an error if feature not found.
  43307. */
  43308. enableFeature(featureName: string | {
  43309. Name: string;
  43310. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43311. /**
  43312. * get the implementation of an enabled feature.
  43313. * @param featureName the name of the feature to load
  43314. * @returns the feature class, if found
  43315. */
  43316. getEnabledFeature(featureName: string): IWebXRFeature;
  43317. /**
  43318. * Get the list of enabled features
  43319. * @returns an array of enabled features
  43320. */
  43321. getEnabledFeatures(): string[];
  43322. }
  43323. }
  43324. declare module BABYLON {
  43325. /**
  43326. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43327. * @see https://doc.babylonjs.com/how_to/webxr
  43328. */
  43329. export class WebXRExperienceHelper implements IDisposable {
  43330. private scene;
  43331. private _nonVRCamera;
  43332. private _originalSceneAutoClear;
  43333. private _supported;
  43334. /**
  43335. * Camera used to render xr content
  43336. */
  43337. camera: WebXRCamera;
  43338. /** A features manager for this xr session */
  43339. featuresManager: WebXRFeaturesManager;
  43340. /**
  43341. * Observers registered here will be triggered after the camera's initial transformation is set
  43342. * This can be used to set a different ground level or an extra rotation.
  43343. *
  43344. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43345. * to the position set after this observable is done executing.
  43346. */
  43347. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43348. /**
  43349. * Fires when the state of the experience helper has changed
  43350. */
  43351. onStateChangedObservable: Observable<WebXRState>;
  43352. /** Session manager used to keep track of xr session */
  43353. sessionManager: WebXRSessionManager;
  43354. /**
  43355. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43356. */
  43357. state: WebXRState;
  43358. /**
  43359. * Creates a WebXRExperienceHelper
  43360. * @param scene The scene the helper should be created in
  43361. */
  43362. private constructor();
  43363. /**
  43364. * Creates the experience helper
  43365. * @param scene the scene to attach the experience helper to
  43366. * @returns a promise for the experience helper
  43367. */
  43368. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43369. /**
  43370. * Disposes of the experience helper
  43371. */
  43372. dispose(): void;
  43373. /**
  43374. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43375. * @param sessionMode options for the XR session
  43376. * @param referenceSpaceType frame of reference of the XR session
  43377. * @param renderTarget the output canvas that will be used to enter XR mode
  43378. * @returns promise that resolves after xr mode has entered
  43379. */
  43380. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43381. /**
  43382. * Exits XR mode and returns the scene to its original state
  43383. * @returns promise that resolves after xr mode has exited
  43384. */
  43385. exitXRAsync(): Promise<void>;
  43386. private _nonXRToXRCamera;
  43387. private _setState;
  43388. }
  43389. }
  43390. declare module BABYLON {
  43391. /**
  43392. * X-Y values for axes in WebXR
  43393. */
  43394. export interface IWebXRMotionControllerAxesValue {
  43395. /**
  43396. * The value of the x axis
  43397. */
  43398. x: number;
  43399. /**
  43400. * The value of the y-axis
  43401. */
  43402. y: number;
  43403. }
  43404. /**
  43405. * changed / previous values for the values of this component
  43406. */
  43407. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43408. /**
  43409. * current (this frame) value
  43410. */
  43411. current: T;
  43412. /**
  43413. * previous (last change) value
  43414. */
  43415. previous: T;
  43416. }
  43417. /**
  43418. * Represents changes in the component between current frame and last values recorded
  43419. */
  43420. export interface IWebXRMotionControllerComponentChanges {
  43421. /**
  43422. * will be populated with previous and current values if axes changed
  43423. */
  43424. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43425. /**
  43426. * will be populated with previous and current values if pressed changed
  43427. */
  43428. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43429. /**
  43430. * will be populated with previous and current values if touched changed
  43431. */
  43432. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43433. /**
  43434. * will be populated with previous and current values if value changed
  43435. */
  43436. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43437. }
  43438. /**
  43439. * This class represents a single component (for example button or thumbstick) of a motion controller
  43440. */
  43441. export class WebXRControllerComponent implements IDisposable {
  43442. /**
  43443. * the id of this component
  43444. */
  43445. id: string;
  43446. /**
  43447. * the type of the component
  43448. */
  43449. type: MotionControllerComponentType;
  43450. private _buttonIndex;
  43451. private _axesIndices;
  43452. private _axes;
  43453. private _changes;
  43454. private _currentValue;
  43455. private _hasChanges;
  43456. private _pressed;
  43457. private _touched;
  43458. /**
  43459. * button component type
  43460. */
  43461. static BUTTON_TYPE: MotionControllerComponentType;
  43462. /**
  43463. * squeeze component type
  43464. */
  43465. static SQUEEZE_TYPE: MotionControllerComponentType;
  43466. /**
  43467. * Thumbstick component type
  43468. */
  43469. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43470. /**
  43471. * Touchpad component type
  43472. */
  43473. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43474. /**
  43475. * trigger component type
  43476. */
  43477. static TRIGGER_TYPE: MotionControllerComponentType;
  43478. /**
  43479. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43480. * the axes data changes
  43481. */
  43482. onAxisValueChangedObservable: Observable<{
  43483. x: number;
  43484. y: number;
  43485. }>;
  43486. /**
  43487. * Observers registered here will be triggered when the state of a button changes
  43488. * State change is either pressed / touched / value
  43489. */
  43490. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43491. /**
  43492. * Creates a new component for a motion controller.
  43493. * It is created by the motion controller itself
  43494. *
  43495. * @param id the id of this component
  43496. * @param type the type of the component
  43497. * @param _buttonIndex index in the buttons array of the gamepad
  43498. * @param _axesIndices indices of the values in the axes array of the gamepad
  43499. */
  43500. constructor(
  43501. /**
  43502. * the id of this component
  43503. */
  43504. id: string,
  43505. /**
  43506. * the type of the component
  43507. */
  43508. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43509. /**
  43510. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43511. */
  43512. get axes(): IWebXRMotionControllerAxesValue;
  43513. /**
  43514. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43515. */
  43516. get changes(): IWebXRMotionControllerComponentChanges;
  43517. /**
  43518. * Return whether or not the component changed the last frame
  43519. */
  43520. get hasChanges(): boolean;
  43521. /**
  43522. * is the button currently pressed
  43523. */
  43524. get pressed(): boolean;
  43525. /**
  43526. * is the button currently touched
  43527. */
  43528. get touched(): boolean;
  43529. /**
  43530. * Get the current value of this component
  43531. */
  43532. get value(): number;
  43533. /**
  43534. * Dispose this component
  43535. */
  43536. dispose(): void;
  43537. /**
  43538. * Are there axes correlating to this component
  43539. * @return true is axes data is available
  43540. */
  43541. isAxes(): boolean;
  43542. /**
  43543. * Is this component a button (hence - pressable)
  43544. * @returns true if can be pressed
  43545. */
  43546. isButton(): boolean;
  43547. /**
  43548. * update this component using the gamepad object it is in. Called on every frame
  43549. * @param nativeController the native gamepad controller object
  43550. */
  43551. update(nativeController: IMinimalMotionControllerObject): void;
  43552. }
  43553. }
  43554. declare module BABYLON {
  43555. /**
  43556. * Class used to represent data loading progression
  43557. */
  43558. export class SceneLoaderProgressEvent {
  43559. /** defines if data length to load can be evaluated */
  43560. readonly lengthComputable: boolean;
  43561. /** defines the loaded data length */
  43562. readonly loaded: number;
  43563. /** defines the data length to load */
  43564. readonly total: number;
  43565. /**
  43566. * Create a new progress event
  43567. * @param lengthComputable defines if data length to load can be evaluated
  43568. * @param loaded defines the loaded data length
  43569. * @param total defines the data length to load
  43570. */
  43571. constructor(
  43572. /** defines if data length to load can be evaluated */
  43573. lengthComputable: boolean,
  43574. /** defines the loaded data length */
  43575. loaded: number,
  43576. /** defines the data length to load */
  43577. total: number);
  43578. /**
  43579. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43580. * @param event defines the source event
  43581. * @returns a new SceneLoaderProgressEvent
  43582. */
  43583. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43584. }
  43585. /**
  43586. * Interface used by SceneLoader plugins to define supported file extensions
  43587. */
  43588. export interface ISceneLoaderPluginExtensions {
  43589. /**
  43590. * Defines the list of supported extensions
  43591. */
  43592. [extension: string]: {
  43593. isBinary: boolean;
  43594. };
  43595. }
  43596. /**
  43597. * Interface used by SceneLoader plugin factory
  43598. */
  43599. export interface ISceneLoaderPluginFactory {
  43600. /**
  43601. * Defines the name of the factory
  43602. */
  43603. name: string;
  43604. /**
  43605. * Function called to create a new plugin
  43606. * @return the new plugin
  43607. */
  43608. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43609. /**
  43610. * The callback that returns true if the data can be directly loaded.
  43611. * @param data string containing the file data
  43612. * @returns if the data can be loaded directly
  43613. */
  43614. canDirectLoad?(data: string): boolean;
  43615. }
  43616. /**
  43617. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43618. */
  43619. export interface ISceneLoaderPluginBase {
  43620. /**
  43621. * The friendly name of this plugin.
  43622. */
  43623. name: string;
  43624. /**
  43625. * The file extensions supported by this plugin.
  43626. */
  43627. extensions: string | ISceneLoaderPluginExtensions;
  43628. /**
  43629. * The callback called when loading from a url.
  43630. * @param scene scene loading this url
  43631. * @param url url to load
  43632. * @param onSuccess callback called when the file successfully loads
  43633. * @param onProgress callback called while file is loading (if the server supports this mode)
  43634. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43635. * @param onError callback called when the file fails to load
  43636. * @returns a file request object
  43637. */
  43638. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43639. /**
  43640. * The callback called when loading from a file object.
  43641. * @param scene scene loading this file
  43642. * @param file defines the file to load
  43643. * @param onSuccess defines the callback to call when data is loaded
  43644. * @param onProgress defines the callback to call during loading process
  43645. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43646. * @param onError defines the callback to call when an error occurs
  43647. * @returns a file request object
  43648. */
  43649. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43650. /**
  43651. * The callback that returns true if the data can be directly loaded.
  43652. * @param data string containing the file data
  43653. * @returns if the data can be loaded directly
  43654. */
  43655. canDirectLoad?(data: string): boolean;
  43656. /**
  43657. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43658. * @param scene scene loading this data
  43659. * @param data string containing the data
  43660. * @returns data to pass to the plugin
  43661. */
  43662. directLoad?(scene: Scene, data: string): any;
  43663. /**
  43664. * The callback that allows custom handling of the root url based on the response url.
  43665. * @param rootUrl the original root url
  43666. * @param responseURL the response url if available
  43667. * @returns the new root url
  43668. */
  43669. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43670. }
  43671. /**
  43672. * Interface used to define a SceneLoader plugin
  43673. */
  43674. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43675. /**
  43676. * Import meshes into a scene.
  43677. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43678. * @param scene The scene to import into
  43679. * @param data The data to import
  43680. * @param rootUrl The root url for scene and resources
  43681. * @param meshes The meshes array to import into
  43682. * @param particleSystems The particle systems array to import into
  43683. * @param skeletons The skeletons array to import into
  43684. * @param onError The callback when import fails
  43685. * @returns True if successful or false otherwise
  43686. */
  43687. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43688. /**
  43689. * Load into a scene.
  43690. * @param scene The scene to load into
  43691. * @param data The data to import
  43692. * @param rootUrl The root url for scene and resources
  43693. * @param onError The callback when import fails
  43694. * @returns True if successful or false otherwise
  43695. */
  43696. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43697. /**
  43698. * Load into an asset container.
  43699. * @param scene The scene to load into
  43700. * @param data The data to import
  43701. * @param rootUrl The root url for scene and resources
  43702. * @param onError The callback when import fails
  43703. * @returns The loaded asset container
  43704. */
  43705. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43706. }
  43707. /**
  43708. * Interface used to define an async SceneLoader plugin
  43709. */
  43710. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43711. /**
  43712. * Import meshes into a scene.
  43713. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43714. * @param scene The scene to import into
  43715. * @param data The data to import
  43716. * @param rootUrl The root url for scene and resources
  43717. * @param onProgress The callback when the load progresses
  43718. * @param fileName Defines the name of the file to load
  43719. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43720. */
  43721. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43722. meshes: AbstractMesh[];
  43723. particleSystems: IParticleSystem[];
  43724. skeletons: Skeleton[];
  43725. animationGroups: AnimationGroup[];
  43726. }>;
  43727. /**
  43728. * Load into a scene.
  43729. * @param scene The scene to load into
  43730. * @param data The data to import
  43731. * @param rootUrl The root url for scene and resources
  43732. * @param onProgress The callback when the load progresses
  43733. * @param fileName Defines the name of the file to load
  43734. * @returns Nothing
  43735. */
  43736. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43737. /**
  43738. * Load into an asset container.
  43739. * @param scene The scene to load into
  43740. * @param data The data to import
  43741. * @param rootUrl The root url for scene and resources
  43742. * @param onProgress The callback when the load progresses
  43743. * @param fileName Defines the name of the file to load
  43744. * @returns The loaded asset container
  43745. */
  43746. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43747. }
  43748. /**
  43749. * Mode that determines how to handle old animation groups before loading new ones.
  43750. */
  43751. export enum SceneLoaderAnimationGroupLoadingMode {
  43752. /**
  43753. * Reset all old animations to initial state then dispose them.
  43754. */
  43755. Clean = 0,
  43756. /**
  43757. * Stop all old animations.
  43758. */
  43759. Stop = 1,
  43760. /**
  43761. * Restart old animations from first frame.
  43762. */
  43763. Sync = 2,
  43764. /**
  43765. * Old animations remains untouched.
  43766. */
  43767. NoSync = 3
  43768. }
  43769. /**
  43770. * Class used to load scene from various file formats using registered plugins
  43771. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43772. */
  43773. export class SceneLoader {
  43774. /**
  43775. * No logging while loading
  43776. */
  43777. static readonly NO_LOGGING: number;
  43778. /**
  43779. * Minimal logging while loading
  43780. */
  43781. static readonly MINIMAL_LOGGING: number;
  43782. /**
  43783. * Summary logging while loading
  43784. */
  43785. static readonly SUMMARY_LOGGING: number;
  43786. /**
  43787. * Detailled logging while loading
  43788. */
  43789. static readonly DETAILED_LOGGING: number;
  43790. /**
  43791. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43792. */
  43793. static get ForceFullSceneLoadingForIncremental(): boolean;
  43794. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43795. /**
  43796. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43797. */
  43798. static get ShowLoadingScreen(): boolean;
  43799. static set ShowLoadingScreen(value: boolean);
  43800. /**
  43801. * Defines the current logging level (while loading the scene)
  43802. * @ignorenaming
  43803. */
  43804. static get loggingLevel(): number;
  43805. static set loggingLevel(value: number);
  43806. /**
  43807. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43808. */
  43809. static get CleanBoneMatrixWeights(): boolean;
  43810. static set CleanBoneMatrixWeights(value: boolean);
  43811. /**
  43812. * Event raised when a plugin is used to load a scene
  43813. */
  43814. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43815. private static _registeredPlugins;
  43816. private static _getDefaultPlugin;
  43817. private static _getPluginForExtension;
  43818. private static _getPluginForDirectLoad;
  43819. private static _getPluginForFilename;
  43820. private static _getDirectLoad;
  43821. private static _loadData;
  43822. private static _getFileInfo;
  43823. /**
  43824. * Gets a plugin that can load the given extension
  43825. * @param extension defines the extension to load
  43826. * @returns a plugin or null if none works
  43827. */
  43828. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43829. /**
  43830. * Gets a boolean indicating that the given extension can be loaded
  43831. * @param extension defines the extension to load
  43832. * @returns true if the extension is supported
  43833. */
  43834. static IsPluginForExtensionAvailable(extension: string): boolean;
  43835. /**
  43836. * Adds a new plugin to the list of registered plugins
  43837. * @param plugin defines the plugin to add
  43838. */
  43839. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43840. /**
  43841. * Import meshes into a scene
  43842. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43843. * @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)
  43844. * @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)
  43845. * @param scene the instance of BABYLON.Scene to append to
  43846. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43847. * @param onProgress a callback with a progress event for each file being loaded
  43848. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43849. * @param pluginExtension the extension used to determine the plugin
  43850. * @returns The loaded plugin
  43851. */
  43852. 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>;
  43853. /**
  43854. * Import meshes into a scene
  43855. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43856. * @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)
  43857. * @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)
  43858. * @param scene the instance of BABYLON.Scene to append to
  43859. * @param onProgress a callback with a progress event for each file being loaded
  43860. * @param pluginExtension the extension used to determine the plugin
  43861. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43862. */
  43863. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43864. meshes: AbstractMesh[];
  43865. particleSystems: IParticleSystem[];
  43866. skeletons: Skeleton[];
  43867. animationGroups: AnimationGroup[];
  43868. }>;
  43869. /**
  43870. * Load a scene
  43871. * @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)
  43872. * @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)
  43873. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43874. * @param onSuccess a callback with the scene when import succeeds
  43875. * @param onProgress a callback with a progress event for each file being loaded
  43876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43877. * @param pluginExtension the extension used to determine the plugin
  43878. * @returns The loaded plugin
  43879. */
  43880. 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>;
  43881. /**
  43882. * Load a scene
  43883. * @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)
  43884. * @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)
  43885. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43886. * @param onProgress a callback with a progress event for each file being loaded
  43887. * @param pluginExtension the extension used to determine the plugin
  43888. * @returns The loaded scene
  43889. */
  43890. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43891. /**
  43892. * Append a scene
  43893. * @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)
  43894. * @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)
  43895. * @param scene is the instance of BABYLON.Scene to append to
  43896. * @param onSuccess a callback with the scene when import succeeds
  43897. * @param onProgress a callback with a progress event for each file being loaded
  43898. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43899. * @param pluginExtension the extension used to determine the plugin
  43900. * @returns The loaded plugin
  43901. */
  43902. 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>;
  43903. /**
  43904. * Append a scene
  43905. * @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)
  43906. * @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)
  43907. * @param scene is the instance of BABYLON.Scene to append to
  43908. * @param onProgress a callback with a progress event for each file being loaded
  43909. * @param pluginExtension the extension used to determine the plugin
  43910. * @returns The given scene
  43911. */
  43912. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43913. /**
  43914. * Load a scene into an asset container
  43915. * @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)
  43916. * @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)
  43917. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43918. * @param onSuccess a callback with the scene when import succeeds
  43919. * @param onProgress a callback with a progress event for each file being loaded
  43920. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43921. * @param pluginExtension the extension used to determine the plugin
  43922. * @returns The loaded plugin
  43923. */
  43924. 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>;
  43925. /**
  43926. * Load a scene into an asset container
  43927. * @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)
  43928. * @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)
  43929. * @param scene is the instance of Scene to append to
  43930. * @param onProgress a callback with a progress event for each file being loaded
  43931. * @param pluginExtension the extension used to determine the plugin
  43932. * @returns The loaded asset container
  43933. */
  43934. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43935. /**
  43936. * Import animations from a file into a scene
  43937. * @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)
  43938. * @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)
  43939. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43940. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43941. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43942. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43943. * @param onSuccess a callback with the scene when import succeeds
  43944. * @param onProgress a callback with a progress event for each file being loaded
  43945. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43946. */
  43947. 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;
  43948. /**
  43949. * Import animations from a file into a scene
  43950. * @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)
  43951. * @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)
  43952. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43953. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43954. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43955. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43956. * @param onSuccess a callback with the scene when import succeeds
  43957. * @param onProgress a callback with a progress event for each file being loaded
  43958. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43959. * @returns the updated scene with imported animations
  43960. */
  43961. 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>;
  43962. }
  43963. }
  43964. declare module BABYLON {
  43965. /**
  43966. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43967. */
  43968. export type MotionControllerHandness = "none" | "left" | "right";
  43969. /**
  43970. * The type of components available in motion controllers.
  43971. * This is not the name of the component.
  43972. */
  43973. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43974. /**
  43975. * The state of a controller component
  43976. */
  43977. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43978. /**
  43979. * The schema of motion controller layout.
  43980. * No object will be initialized using this interface
  43981. * This is used just to define the profile.
  43982. */
  43983. export interface IMotionControllerLayout {
  43984. /**
  43985. * Path to load the assets. Usually relative to the base path
  43986. */
  43987. assetPath: string;
  43988. /**
  43989. * Available components (unsorted)
  43990. */
  43991. components: {
  43992. /**
  43993. * A map of component Ids
  43994. */
  43995. [componentId: string]: {
  43996. /**
  43997. * The type of input the component outputs
  43998. */
  43999. type: MotionControllerComponentType;
  44000. /**
  44001. * The indices of this component in the gamepad object
  44002. */
  44003. gamepadIndices: {
  44004. /**
  44005. * Index of button
  44006. */
  44007. button?: number;
  44008. /**
  44009. * If available, index of x-axis
  44010. */
  44011. xAxis?: number;
  44012. /**
  44013. * If available, index of y-axis
  44014. */
  44015. yAxis?: number;
  44016. };
  44017. /**
  44018. * The mesh's root node name
  44019. */
  44020. rootNodeName: string;
  44021. /**
  44022. * Animation definitions for this model
  44023. */
  44024. visualResponses: {
  44025. [stateKey: string]: {
  44026. /**
  44027. * What property will be animated
  44028. */
  44029. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44030. /**
  44031. * What states influence this visual response
  44032. */
  44033. states: MotionControllerComponentStateType[];
  44034. /**
  44035. * Type of animation - movement or visibility
  44036. */
  44037. valueNodeProperty: "transform" | "visibility";
  44038. /**
  44039. * Base node name to move. Its position will be calculated according to the min and max nodes
  44040. */
  44041. valueNodeName?: string;
  44042. /**
  44043. * Minimum movement node
  44044. */
  44045. minNodeName?: string;
  44046. /**
  44047. * Max movement node
  44048. */
  44049. maxNodeName?: string;
  44050. };
  44051. };
  44052. /**
  44053. * If touch enabled, what is the name of node to display user feedback
  44054. */
  44055. touchPointNodeName?: string;
  44056. };
  44057. };
  44058. /**
  44059. * Is it xr standard mapping or not
  44060. */
  44061. gamepadMapping: "" | "xr-standard";
  44062. /**
  44063. * Base root node of this entire model
  44064. */
  44065. rootNodeName: string;
  44066. /**
  44067. * Defines the main button component id
  44068. */
  44069. selectComponentId: string;
  44070. }
  44071. /**
  44072. * A definition for the layout map in the input profile
  44073. */
  44074. export interface IMotionControllerLayoutMap {
  44075. /**
  44076. * Layouts with handness type as a key
  44077. */
  44078. [handness: string]: IMotionControllerLayout;
  44079. }
  44080. /**
  44081. * The XR Input profile schema
  44082. * Profiles can be found here:
  44083. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44084. */
  44085. export interface IMotionControllerProfile {
  44086. /**
  44087. * fallback profiles for this profileId
  44088. */
  44089. fallbackProfileIds: string[];
  44090. /**
  44091. * The layout map, with handness as key
  44092. */
  44093. layouts: IMotionControllerLayoutMap;
  44094. /**
  44095. * The id of this profile
  44096. * correlates to the profile(s) in the xrInput.profiles array
  44097. */
  44098. profileId: string;
  44099. }
  44100. /**
  44101. * A helper-interface for the 3 meshes needed for controller button animation
  44102. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44103. */
  44104. export interface IMotionControllerButtonMeshMap {
  44105. /**
  44106. * the mesh that defines the pressed value mesh position.
  44107. * This is used to find the max-position of this button
  44108. */
  44109. pressedMesh: AbstractMesh;
  44110. /**
  44111. * the mesh that defines the unpressed value mesh position.
  44112. * This is used to find the min (or initial) position of this button
  44113. */
  44114. unpressedMesh: AbstractMesh;
  44115. /**
  44116. * The mesh that will be changed when value changes
  44117. */
  44118. valueMesh: AbstractMesh;
  44119. }
  44120. /**
  44121. * A helper-interface for the 3 meshes needed for controller axis animation.
  44122. * This will be expanded when touchpad animations are fully supported
  44123. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44124. */
  44125. export interface IMotionControllerMeshMap {
  44126. /**
  44127. * the mesh that defines the maximum value mesh position.
  44128. */
  44129. maxMesh?: AbstractMesh;
  44130. /**
  44131. * the mesh that defines the minimum value mesh position.
  44132. */
  44133. minMesh?: AbstractMesh;
  44134. /**
  44135. * The mesh that will be changed when axis value changes
  44136. */
  44137. valueMesh: AbstractMesh;
  44138. }
  44139. /**
  44140. * The elements needed for change-detection of the gamepad objects in motion controllers
  44141. */
  44142. export interface IMinimalMotionControllerObject {
  44143. /**
  44144. * Available axes of this controller
  44145. */
  44146. axes: number[];
  44147. /**
  44148. * An array of available buttons
  44149. */
  44150. buttons: Array<{
  44151. /**
  44152. * Value of the button/trigger
  44153. */
  44154. value: number;
  44155. /**
  44156. * If the button/trigger is currently touched
  44157. */
  44158. touched: boolean;
  44159. /**
  44160. * If the button/trigger is currently pressed
  44161. */
  44162. pressed: boolean;
  44163. }>;
  44164. }
  44165. /**
  44166. * An Abstract Motion controller
  44167. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44168. * Each component has an observable to check for changes in value and state
  44169. */
  44170. export abstract class WebXRAbstractMotionController implements IDisposable {
  44171. protected scene: Scene;
  44172. protected layout: IMotionControllerLayout;
  44173. /**
  44174. * The gamepad object correlating to this controller
  44175. */
  44176. gamepadObject: IMinimalMotionControllerObject;
  44177. /**
  44178. * handness (left/right/none) of this controller
  44179. */
  44180. handness: MotionControllerHandness;
  44181. private _initComponent;
  44182. private _modelReady;
  44183. /**
  44184. * A map of components (WebXRControllerComponent) in this motion controller
  44185. * Components have a ComponentType and can also have both button and axis definitions
  44186. */
  44187. readonly components: {
  44188. [id: string]: WebXRControllerComponent;
  44189. };
  44190. /**
  44191. * Disable the model's animation. Can be set at any time.
  44192. */
  44193. disableAnimation: boolean;
  44194. /**
  44195. * Observers registered here will be triggered when the model of this controller is done loading
  44196. */
  44197. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44198. /**
  44199. * The profile id of this motion controller
  44200. */
  44201. abstract profileId: string;
  44202. /**
  44203. * The root mesh of the model. It is null if the model was not yet initialized
  44204. */
  44205. rootMesh: Nullable<AbstractMesh>;
  44206. /**
  44207. * constructs a new abstract motion controller
  44208. * @param scene the scene to which the model of the controller will be added
  44209. * @param layout The profile layout to load
  44210. * @param gamepadObject The gamepad object correlating to this controller
  44211. * @param handness handness (left/right/none) of this controller
  44212. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44213. */
  44214. constructor(scene: Scene, layout: IMotionControllerLayout,
  44215. /**
  44216. * The gamepad object correlating to this controller
  44217. */
  44218. gamepadObject: IMinimalMotionControllerObject,
  44219. /**
  44220. * handness (left/right/none) of this controller
  44221. */
  44222. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44223. /**
  44224. * Dispose this controller, the model mesh and all its components
  44225. */
  44226. dispose(): void;
  44227. /**
  44228. * Returns all components of specific type
  44229. * @param type the type to search for
  44230. * @return an array of components with this type
  44231. */
  44232. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44233. /**
  44234. * get a component based an its component id as defined in layout.components
  44235. * @param id the id of the component
  44236. * @returns the component correlates to the id or undefined if not found
  44237. */
  44238. getComponent(id: string): WebXRControllerComponent;
  44239. /**
  44240. * Get the list of components available in this motion controller
  44241. * @returns an array of strings correlating to available components
  44242. */
  44243. getComponentIds(): string[];
  44244. /**
  44245. * Get the first component of specific type
  44246. * @param type type of component to find
  44247. * @return a controller component or null if not found
  44248. */
  44249. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44250. /**
  44251. * Get the main (Select) component of this controller as defined in the layout
  44252. * @returns the main component of this controller
  44253. */
  44254. getMainComponent(): WebXRControllerComponent;
  44255. /**
  44256. * Loads the model correlating to this controller
  44257. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44258. * @returns A promise fulfilled with the result of the model loading
  44259. */
  44260. loadModel(): Promise<boolean>;
  44261. /**
  44262. * Update this model using the current XRFrame
  44263. * @param xrFrame the current xr frame to use and update the model
  44264. */
  44265. updateFromXRFrame(xrFrame: XRFrame): void;
  44266. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44267. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44268. /**
  44269. * Moves the axis on the controller mesh based on its current state
  44270. * @param axis the index of the axis
  44271. * @param axisValue the value of the axis which determines the meshes new position
  44272. * @hidden
  44273. */
  44274. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44275. /**
  44276. * Update the model itself with the current frame data
  44277. * @param xrFrame the frame to use for updating the model mesh
  44278. */
  44279. protected updateModel(xrFrame: XRFrame): void;
  44280. /**
  44281. * Get the filename and path for this controller's model
  44282. * @returns a map of filename and path
  44283. */
  44284. protected abstract _getFilenameAndPath(): {
  44285. filename: string;
  44286. path: string;
  44287. };
  44288. /**
  44289. * This function is called before the mesh is loaded. It checks for loading constraints.
  44290. * For example, this function can check if the GLB loader is available
  44291. * If this function returns false, the generic controller will be loaded instead
  44292. * @returns Is the client ready to load the mesh
  44293. */
  44294. protected abstract _getModelLoadingConstraints(): boolean;
  44295. /**
  44296. * This function will be called after the model was successfully loaded and can be used
  44297. * for mesh transformations before it is available for the user
  44298. * @param meshes the loaded meshes
  44299. */
  44300. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44301. /**
  44302. * Set the root mesh for this controller. Important for the WebXR controller class
  44303. * @param meshes the loaded meshes
  44304. */
  44305. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44306. /**
  44307. * A function executed each frame that updates the mesh (if needed)
  44308. * @param xrFrame the current xrFrame
  44309. */
  44310. protected abstract _updateModel(xrFrame: XRFrame): void;
  44311. private _getGenericFilenameAndPath;
  44312. private _getGenericParentMesh;
  44313. }
  44314. }
  44315. declare module BABYLON {
  44316. /**
  44317. * A generic trigger-only motion controller for WebXR
  44318. */
  44319. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44320. /**
  44321. * Static version of the profile id of this controller
  44322. */
  44323. static ProfileId: string;
  44324. profileId: string;
  44325. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44326. protected _getFilenameAndPath(): {
  44327. filename: string;
  44328. path: string;
  44329. };
  44330. protected _getModelLoadingConstraints(): boolean;
  44331. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44332. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44333. protected _updateModel(): void;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /**
  44338. * Class containing static functions to help procedurally build meshes
  44339. */
  44340. export class SphereBuilder {
  44341. /**
  44342. * Creates a sphere mesh
  44343. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44344. * * 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`)
  44345. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44346. * * 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
  44347. * * 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)
  44348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44349. * * 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
  44350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44351. * @param name defines the name of the mesh
  44352. * @param options defines the options used to create the mesh
  44353. * @param scene defines the hosting scene
  44354. * @returns the sphere mesh
  44355. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44356. */
  44357. static CreateSphere(name: string, options: {
  44358. segments?: number;
  44359. diameter?: number;
  44360. diameterX?: number;
  44361. diameterY?: number;
  44362. diameterZ?: number;
  44363. arc?: number;
  44364. slice?: number;
  44365. sideOrientation?: number;
  44366. frontUVs?: Vector4;
  44367. backUVs?: Vector4;
  44368. updatable?: boolean;
  44369. }, scene?: Nullable<Scene>): Mesh;
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. /**
  44374. * A profiled motion controller has its profile loaded from an online repository.
  44375. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44376. */
  44377. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44378. private _repositoryUrl;
  44379. private _buttonMeshMapping;
  44380. private _touchDots;
  44381. /**
  44382. * The profile ID of this controller. Will be populated when the controller initializes.
  44383. */
  44384. profileId: string;
  44385. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44386. dispose(): void;
  44387. protected _getFilenameAndPath(): {
  44388. filename: string;
  44389. path: string;
  44390. };
  44391. protected _getModelLoadingConstraints(): boolean;
  44392. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44393. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44394. protected _updateModel(_xrFrame: XRFrame): void;
  44395. }
  44396. }
  44397. declare module BABYLON {
  44398. /**
  44399. * A construction function type to create a new controller based on an xrInput object
  44400. */
  44401. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44402. /**
  44403. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44404. *
  44405. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44406. * it should be replaced with auto-loaded controllers.
  44407. *
  44408. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44409. */
  44410. export class WebXRMotionControllerManager {
  44411. private static _AvailableControllers;
  44412. private static _Fallbacks;
  44413. private static _ProfileLoadingPromises;
  44414. private static _ProfilesList;
  44415. /**
  44416. * The base URL of the online controller repository. Can be changed at any time.
  44417. */
  44418. static BaseRepositoryUrl: string;
  44419. /**
  44420. * Which repository gets priority - local or online
  44421. */
  44422. static PrioritizeOnlineRepository: boolean;
  44423. /**
  44424. * Use the online repository, or use only locally-defined controllers
  44425. */
  44426. static UseOnlineRepository: boolean;
  44427. /**
  44428. * Clear the cache used for profile loading and reload when requested again
  44429. */
  44430. static ClearProfilesCache(): void;
  44431. /**
  44432. * Register the default fallbacks.
  44433. * This function is called automatically when this file is imported.
  44434. */
  44435. static DefaultFallbacks(): void;
  44436. /**
  44437. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44438. * @param profileId the profile to which a fallback needs to be found
  44439. * @return an array with corresponding fallback profiles
  44440. */
  44441. static FindFallbackWithProfileId(profileId: string): string[];
  44442. /**
  44443. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44444. * The order of search:
  44445. *
  44446. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44447. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44448. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44449. * 4) return the generic trigger controller if none were found
  44450. *
  44451. * @param xrInput the xrInput to which a new controller is initialized
  44452. * @param scene the scene to which the model will be added
  44453. * @param forceProfile force a certain profile for this controller
  44454. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44455. */
  44456. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44457. /**
  44458. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44459. *
  44460. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44461. *
  44462. * @param type the profile type to register
  44463. * @param constructFunction the function to be called when loading this profile
  44464. */
  44465. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44466. /**
  44467. * Register a fallback to a specific profile.
  44468. * @param profileId the profileId that will receive the fallbacks
  44469. * @param fallbacks A list of fallback profiles
  44470. */
  44471. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44472. /**
  44473. * Will update the list of profiles available in the repository
  44474. * @return a promise that resolves to a map of profiles available online
  44475. */
  44476. static UpdateProfilesList(): Promise<{
  44477. [profile: string]: string;
  44478. }>;
  44479. private static _LoadProfileFromRepository;
  44480. private static _LoadProfilesFromAvailableControllers;
  44481. }
  44482. }
  44483. declare module BABYLON {
  44484. /**
  44485. * Configuration options for the WebXR controller creation
  44486. */
  44487. export interface IWebXRControllerOptions {
  44488. /**
  44489. * Should the controller mesh be animated when a user interacts with it
  44490. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44491. */
  44492. disableMotionControllerAnimation?: boolean;
  44493. /**
  44494. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44495. */
  44496. doNotLoadControllerMesh?: boolean;
  44497. /**
  44498. * Force a specific controller type for this controller.
  44499. * This can be used when creating your own profile or when testing different controllers
  44500. */
  44501. forceControllerProfile?: string;
  44502. }
  44503. /**
  44504. * Represents an XR controller
  44505. */
  44506. export class WebXRInputSource {
  44507. private _scene;
  44508. /** The underlying input source for the controller */
  44509. inputSource: XRInputSource;
  44510. private _options;
  44511. private _tmpQuaternion;
  44512. private _tmpVector;
  44513. private _uniqueId;
  44514. /**
  44515. * 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
  44516. */
  44517. grip?: AbstractMesh;
  44518. /**
  44519. * If available, this is the gamepad object related to this controller.
  44520. * Using this object it is possible to get click events and trackpad changes of the
  44521. * webxr controller that is currently being used.
  44522. */
  44523. motionController?: WebXRAbstractMotionController;
  44524. /**
  44525. * Event that fires when the controller is removed/disposed.
  44526. * The object provided as event data is this controller, after associated assets were disposed.
  44527. * uniqueId is still available.
  44528. */
  44529. onDisposeObservable: Observable<WebXRInputSource>;
  44530. /**
  44531. * Will be triggered when the mesh associated with the motion controller is done loading.
  44532. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44533. * A shortened version of controller -> motion controller -> on mesh loaded.
  44534. */
  44535. onMeshLoadedObservable: Observable<AbstractMesh>;
  44536. /**
  44537. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44538. */
  44539. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44540. /**
  44541. * Pointer which can be used to select objects or attach a visible laser to
  44542. */
  44543. pointer: AbstractMesh;
  44544. /**
  44545. * Creates the controller
  44546. * @see https://doc.babylonjs.com/how_to/webxr
  44547. * @param _scene the scene which the controller should be associated to
  44548. * @param inputSource the underlying input source for the controller
  44549. * @param _options options for this controller creation
  44550. */
  44551. constructor(_scene: Scene,
  44552. /** The underlying input source for the controller */
  44553. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44554. /**
  44555. * Get this controllers unique id
  44556. */
  44557. get uniqueId(): string;
  44558. /**
  44559. * Disposes of the object
  44560. */
  44561. dispose(): void;
  44562. /**
  44563. * Gets a world space ray coming from the pointer or grip
  44564. * @param result the resulting ray
  44565. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44566. */
  44567. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44568. /**
  44569. * Updates the controller pose based on the given XRFrame
  44570. * @param xrFrame xr frame to update the pose with
  44571. * @param referenceSpace reference space to use
  44572. */
  44573. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44574. }
  44575. }
  44576. declare module BABYLON {
  44577. /**
  44578. * The schema for initialization options of the XR Input class
  44579. */
  44580. export interface IWebXRInputOptions {
  44581. /**
  44582. * If set to true no model will be automatically loaded
  44583. */
  44584. doNotLoadControllerMeshes?: boolean;
  44585. /**
  44586. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44587. * If not found, the xr input profile data will be used.
  44588. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44589. */
  44590. forceInputProfile?: string;
  44591. /**
  44592. * Do not send a request to the controller repository to load the profile.
  44593. *
  44594. * Instead, use the controllers available in babylon itself.
  44595. */
  44596. disableOnlineControllerRepository?: boolean;
  44597. /**
  44598. * A custom URL for the controllers repository
  44599. */
  44600. customControllersRepositoryURL?: string;
  44601. /**
  44602. * Should the controller model's components not move according to the user input
  44603. */
  44604. disableControllerAnimation?: boolean;
  44605. }
  44606. /**
  44607. * XR input used to track XR inputs such as controllers/rays
  44608. */
  44609. export class WebXRInput implements IDisposable {
  44610. /**
  44611. * the xr session manager for this session
  44612. */
  44613. xrSessionManager: WebXRSessionManager;
  44614. /**
  44615. * the WebXR camera for this session. Mainly used for teleportation
  44616. */
  44617. xrCamera: WebXRCamera;
  44618. private readonly options;
  44619. /**
  44620. * XR controllers being tracked
  44621. */
  44622. controllers: Array<WebXRInputSource>;
  44623. private _frameObserver;
  44624. private _sessionEndedObserver;
  44625. private _sessionInitObserver;
  44626. /**
  44627. * Event when a controller has been connected/added
  44628. */
  44629. onControllerAddedObservable: Observable<WebXRInputSource>;
  44630. /**
  44631. * Event when a controller has been removed/disconnected
  44632. */
  44633. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44634. /**
  44635. * Initializes the WebXRInput
  44636. * @param xrSessionManager the xr session manager for this session
  44637. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44638. * @param options = initialization options for this xr input
  44639. */
  44640. constructor(
  44641. /**
  44642. * the xr session manager for this session
  44643. */
  44644. xrSessionManager: WebXRSessionManager,
  44645. /**
  44646. * the WebXR camera for this session. Mainly used for teleportation
  44647. */
  44648. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44649. private _onInputSourcesChange;
  44650. private _addAndRemoveControllers;
  44651. /**
  44652. * Disposes of the object
  44653. */
  44654. dispose(): void;
  44655. }
  44656. }
  44657. declare module BABYLON {
  44658. /**
  44659. * This is the base class for all WebXR features.
  44660. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44661. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44662. */
  44663. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44664. protected _xrSessionManager: WebXRSessionManager;
  44665. private _attached;
  44666. private _removeOnDetach;
  44667. /**
  44668. * Should auto-attach be disabled?
  44669. */
  44670. disableAutoAttach: boolean;
  44671. /**
  44672. * Construct a new (abstract) WebXR feature
  44673. * @param _xrSessionManager the xr session manager for this feature
  44674. */
  44675. constructor(_xrSessionManager: WebXRSessionManager);
  44676. /**
  44677. * Is this feature attached
  44678. */
  44679. get attached(): boolean;
  44680. /**
  44681. * attach this feature
  44682. *
  44683. * @param force should attachment be forced (even when already attached)
  44684. * @returns true if successful, false is failed or already attached
  44685. */
  44686. attach(force?: boolean): boolean;
  44687. /**
  44688. * detach this feature.
  44689. *
  44690. * @returns true if successful, false if failed or already detached
  44691. */
  44692. detach(): boolean;
  44693. /**
  44694. * Dispose this feature and all of the resources attached
  44695. */
  44696. dispose(): void;
  44697. /**
  44698. * This is used to register callbacks that will automatically be removed when detach is called.
  44699. * @param observable the observable to which the observer will be attached
  44700. * @param callback the callback to register
  44701. */
  44702. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44703. /**
  44704. * Code in this function will be executed on each xrFrame received from the browser.
  44705. * This function will not execute after the feature is detached.
  44706. * @param _xrFrame the current frame
  44707. */
  44708. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44709. }
  44710. }
  44711. declare module BABYLON {
  44712. /**
  44713. * Renders a layer on top of an existing scene
  44714. */
  44715. export class UtilityLayerRenderer implements IDisposable {
  44716. /** the original scene that will be rendered on top of */
  44717. originalScene: Scene;
  44718. private _pointerCaptures;
  44719. private _lastPointerEvents;
  44720. private static _DefaultUtilityLayer;
  44721. private static _DefaultKeepDepthUtilityLayer;
  44722. private _sharedGizmoLight;
  44723. private _renderCamera;
  44724. /**
  44725. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44726. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44727. * @returns the camera that is used when rendering the utility layer
  44728. */
  44729. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44730. /**
  44731. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44732. * @param cam the camera that should be used when rendering the utility layer
  44733. */
  44734. setRenderCamera(cam: Nullable<Camera>): void;
  44735. /**
  44736. * @hidden
  44737. * Light which used by gizmos to get light shading
  44738. */
  44739. _getSharedGizmoLight(): HemisphericLight;
  44740. /**
  44741. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44742. */
  44743. pickUtilitySceneFirst: boolean;
  44744. /**
  44745. * 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)
  44746. */
  44747. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44748. /**
  44749. * 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)
  44750. */
  44751. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44752. /**
  44753. * The scene that is rendered on top of the original scene
  44754. */
  44755. utilityLayerScene: Scene;
  44756. /**
  44757. * If the utility layer should automatically be rendered on top of existing scene
  44758. */
  44759. shouldRender: boolean;
  44760. /**
  44761. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44762. */
  44763. onlyCheckPointerDownEvents: boolean;
  44764. /**
  44765. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44766. */
  44767. processAllEvents: boolean;
  44768. /**
  44769. * Observable raised when the pointer move from the utility layer scene to the main scene
  44770. */
  44771. onPointerOutObservable: Observable<number>;
  44772. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44773. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44774. private _afterRenderObserver;
  44775. private _sceneDisposeObserver;
  44776. private _originalPointerObserver;
  44777. /**
  44778. * Instantiates a UtilityLayerRenderer
  44779. * @param originalScene the original scene that will be rendered on top of
  44780. * @param handleEvents boolean indicating if the utility layer should handle events
  44781. */
  44782. constructor(
  44783. /** the original scene that will be rendered on top of */
  44784. originalScene: Scene, handleEvents?: boolean);
  44785. private _notifyObservers;
  44786. /**
  44787. * Renders the utility layers scene on top of the original scene
  44788. */
  44789. render(): void;
  44790. /**
  44791. * Disposes of the renderer
  44792. */
  44793. dispose(): void;
  44794. private _updateCamera;
  44795. }
  44796. }
  44797. declare module BABYLON {
  44798. /**
  44799. * Options interface for the pointer selection module
  44800. */
  44801. export interface IWebXRControllerPointerSelectionOptions {
  44802. /**
  44803. * if provided, this scene will be used to render meshes.
  44804. */
  44805. customUtilityLayerScene?: Scene;
  44806. /**
  44807. * 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)
  44808. * If not disabled, the last picked point will be used to execute a pointer up event
  44809. * If disabled, pointer up event will be triggered right after the pointer down event.
  44810. * Used in screen and gaze target ray mode only
  44811. */
  44812. disablePointerUpOnTouchOut: boolean;
  44813. /**
  44814. * For gaze mode (time to select instead of press)
  44815. */
  44816. forceGazeMode: boolean;
  44817. /**
  44818. * 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
  44819. * to start a new countdown to the pointer down event.
  44820. * Defaults to 1.
  44821. */
  44822. gazeModePointerMovedFactor?: number;
  44823. /**
  44824. * Different button type to use instead of the main component
  44825. */
  44826. overrideButtonId?: string;
  44827. /**
  44828. * use this rendering group id for the meshes (optional)
  44829. */
  44830. renderingGroupId?: number;
  44831. /**
  44832. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44833. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44834. * 3000 means 3 seconds between pointing at something and selecting it
  44835. */
  44836. timeToSelect?: number;
  44837. /**
  44838. * Should meshes created here be added to a utility layer or the main scene
  44839. */
  44840. useUtilityLayer?: boolean;
  44841. /**
  44842. * the xr input to use with this pointer selection
  44843. */
  44844. xrInput: WebXRInput;
  44845. }
  44846. /**
  44847. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44848. */
  44849. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44850. private readonly _options;
  44851. private static _idCounter;
  44852. private _attachController;
  44853. private _controllers;
  44854. private _scene;
  44855. private _tmpVectorForPickCompare;
  44856. /**
  44857. * The module's name
  44858. */
  44859. static readonly Name: string;
  44860. /**
  44861. * The (Babylon) version of this module.
  44862. * This is an integer representing the implementation version.
  44863. * This number does not correspond to the WebXR specs version
  44864. */
  44865. static readonly Version: number;
  44866. /**
  44867. * Disable lighting on the laser pointer (so it will always be visible)
  44868. */
  44869. disablePointerLighting: boolean;
  44870. /**
  44871. * Disable lighting on the selection mesh (so it will always be visible)
  44872. */
  44873. disableSelectionMeshLighting: boolean;
  44874. /**
  44875. * Should the laser pointer be displayed
  44876. */
  44877. displayLaserPointer: boolean;
  44878. /**
  44879. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44880. */
  44881. displaySelectionMesh: boolean;
  44882. /**
  44883. * This color will be set to the laser pointer when selection is triggered
  44884. */
  44885. laserPointerPickedColor: Color3;
  44886. /**
  44887. * Default color of the laser pointer
  44888. */
  44889. lasterPointerDefaultColor: Color3;
  44890. /**
  44891. * default color of the selection ring
  44892. */
  44893. selectionMeshDefaultColor: Color3;
  44894. /**
  44895. * This color will be applied to the selection ring when selection is triggered
  44896. */
  44897. selectionMeshPickedColor: Color3;
  44898. /**
  44899. * Optional filter to be used for ray selection. This predicate shares behavior with
  44900. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44901. */
  44902. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44903. /**
  44904. * constructs a new background remover module
  44905. * @param _xrSessionManager the session manager for this module
  44906. * @param _options read-only options to be used in this module
  44907. */
  44908. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44909. /**
  44910. * attach this feature
  44911. * Will usually be called by the features manager
  44912. *
  44913. * @returns true if successful.
  44914. */
  44915. attach(): boolean;
  44916. /**
  44917. * detach this feature.
  44918. * Will usually be called by the features manager
  44919. *
  44920. * @returns true if successful.
  44921. */
  44922. detach(): boolean;
  44923. /**
  44924. * Will get the mesh under a specific pointer.
  44925. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44926. * @param controllerId the controllerId to check
  44927. * @returns The mesh under pointer or null if no mesh is under the pointer
  44928. */
  44929. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44930. /**
  44931. * Get the xr controller that correlates to the pointer id in the pointer event
  44932. *
  44933. * @param id the pointer id to search for
  44934. * @returns the controller that correlates to this id or null if not found
  44935. */
  44936. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44937. protected _onXRFrame(_xrFrame: XRFrame): void;
  44938. private _attachGazeMode;
  44939. private _attachScreenRayMode;
  44940. private _attachTrackedPointerRayMode;
  44941. private _convertNormalToDirectionOfRay;
  44942. private _detachController;
  44943. private _generateNewMeshPair;
  44944. private _pickingMoved;
  44945. private _updatePointerDistance;
  44946. }
  44947. }
  44948. declare module BABYLON {
  44949. /**
  44950. * Button which can be used to enter a different mode of XR
  44951. */
  44952. export class WebXREnterExitUIButton {
  44953. /** button element */
  44954. element: HTMLElement;
  44955. /** XR initialization options for the button */
  44956. sessionMode: XRSessionMode;
  44957. /** Reference space type */
  44958. referenceSpaceType: XRReferenceSpaceType;
  44959. /**
  44960. * Creates a WebXREnterExitUIButton
  44961. * @param element button element
  44962. * @param sessionMode XR initialization session mode
  44963. * @param referenceSpaceType the type of reference space to be used
  44964. */
  44965. constructor(
  44966. /** button element */
  44967. element: HTMLElement,
  44968. /** XR initialization options for the button */
  44969. sessionMode: XRSessionMode,
  44970. /** Reference space type */
  44971. referenceSpaceType: XRReferenceSpaceType);
  44972. /**
  44973. * Extendable function which can be used to update the button's visuals when the state changes
  44974. * @param activeButton the current active button in the UI
  44975. */
  44976. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44977. }
  44978. /**
  44979. * Options to create the webXR UI
  44980. */
  44981. export class WebXREnterExitUIOptions {
  44982. /**
  44983. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44984. */
  44985. customButtons?: Array<WebXREnterExitUIButton>;
  44986. /**
  44987. * A reference space type to use when creating the default button.
  44988. * Default is local-floor
  44989. */
  44990. referenceSpaceType?: XRReferenceSpaceType;
  44991. /**
  44992. * Context to enter xr with
  44993. */
  44994. renderTarget?: Nullable<WebXRRenderTarget>;
  44995. /**
  44996. * A session mode to use when creating the default button.
  44997. * Default is immersive-vr
  44998. */
  44999. sessionMode?: XRSessionMode;
  45000. }
  45001. /**
  45002. * UI to allow the user to enter/exit XR mode
  45003. */
  45004. export class WebXREnterExitUI implements IDisposable {
  45005. private scene;
  45006. /** version of the options passed to this UI */
  45007. options: WebXREnterExitUIOptions;
  45008. private _activeButton;
  45009. private _buttons;
  45010. private _overlay;
  45011. /**
  45012. * Fired every time the active button is changed.
  45013. *
  45014. * When xr is entered via a button that launches xr that button will be the callback parameter
  45015. *
  45016. * When exiting xr the callback parameter will be null)
  45017. */
  45018. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45019. /**
  45020. *
  45021. * @param scene babylon scene object to use
  45022. * @param options (read-only) version of the options passed to this UI
  45023. */
  45024. private constructor();
  45025. /**
  45026. * Creates UI to allow the user to enter/exit XR mode
  45027. * @param scene the scene to add the ui to
  45028. * @param helper the xr experience helper to enter/exit xr with
  45029. * @param options options to configure the UI
  45030. * @returns the created ui
  45031. */
  45032. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45033. /**
  45034. * Disposes of the XR UI component
  45035. */
  45036. dispose(): void;
  45037. private _updateButtons;
  45038. }
  45039. }
  45040. declare module BABYLON {
  45041. /**
  45042. * Class containing static functions to help procedurally build meshes
  45043. */
  45044. export class LinesBuilder {
  45045. /**
  45046. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45047. * * 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
  45048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45049. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45050. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45051. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45053. * * 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
  45054. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45057. * @param name defines the name of the new line system
  45058. * @param options defines the options used to create the line system
  45059. * @param scene defines the hosting scene
  45060. * @returns a new line system mesh
  45061. */
  45062. static CreateLineSystem(name: string, options: {
  45063. lines: Vector3[][];
  45064. updatable?: boolean;
  45065. instance?: Nullable<LinesMesh>;
  45066. colors?: Nullable<Color4[][]>;
  45067. useVertexAlpha?: boolean;
  45068. }, scene: Nullable<Scene>): LinesMesh;
  45069. /**
  45070. * Creates a line mesh
  45071. * 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
  45072. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45073. * * The parameter `points` is an array successive Vector3
  45074. * * 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
  45075. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45076. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45077. * * When updating an instance, remember that only point positions can change, not the number of points
  45078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45080. * @param name defines the name of the new line system
  45081. * @param options defines the options used to create the line system
  45082. * @param scene defines the hosting scene
  45083. * @returns a new line mesh
  45084. */
  45085. static CreateLines(name: string, options: {
  45086. points: Vector3[];
  45087. updatable?: boolean;
  45088. instance?: Nullable<LinesMesh>;
  45089. colors?: Color4[];
  45090. useVertexAlpha?: boolean;
  45091. }, scene?: Nullable<Scene>): LinesMesh;
  45092. /**
  45093. * Creates a dashed line mesh
  45094. * * 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
  45095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45096. * * The parameter `points` is an array successive Vector3
  45097. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45098. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45099. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45100. * * 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
  45101. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45102. * * When updating an instance, remember that only point positions can change, not the number of points
  45103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45104. * @param name defines the name of the mesh
  45105. * @param options defines the options used to create the mesh
  45106. * @param scene defines the hosting scene
  45107. * @returns the dashed line mesh
  45108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45109. */
  45110. static CreateDashedLines(name: string, options: {
  45111. points: Vector3[];
  45112. dashSize?: number;
  45113. gapSize?: number;
  45114. dashNb?: number;
  45115. updatable?: boolean;
  45116. instance?: LinesMesh;
  45117. useVertexAlpha?: boolean;
  45118. }, scene?: Nullable<Scene>): LinesMesh;
  45119. }
  45120. }
  45121. declare module BABYLON {
  45122. /**
  45123. * The options container for the teleportation module
  45124. */
  45125. export interface IWebXRTeleportationOptions {
  45126. /**
  45127. * if provided, this scene will be used to render meshes.
  45128. */
  45129. customUtilityLayerScene?: Scene;
  45130. /**
  45131. * Values to configure the default target mesh
  45132. */
  45133. defaultTargetMeshOptions?: {
  45134. /**
  45135. * Fill color of the teleportation area
  45136. */
  45137. teleportationFillColor?: string;
  45138. /**
  45139. * Border color for the teleportation area
  45140. */
  45141. teleportationBorderColor?: string;
  45142. /**
  45143. * Disable the mesh's animation sequence
  45144. */
  45145. disableAnimation?: boolean;
  45146. /**
  45147. * Disable lighting on the material or the ring and arrow
  45148. */
  45149. disableLighting?: boolean;
  45150. /**
  45151. * Override the default material of the torus and arrow
  45152. */
  45153. torusArrowMaterial?: Material;
  45154. };
  45155. /**
  45156. * A list of meshes to use as floor meshes.
  45157. * Meshes can be added and removed after initializing the feature using the
  45158. * addFloorMesh and removeFloorMesh functions
  45159. * If empty, rotation will still work
  45160. */
  45161. floorMeshes?: AbstractMesh[];
  45162. /**
  45163. * use this rendering group id for the meshes (optional)
  45164. */
  45165. renderingGroupId?: number;
  45166. /**
  45167. * Should teleportation move only to snap points
  45168. */
  45169. snapPointsOnly?: boolean;
  45170. /**
  45171. * An array of points to which the teleportation will snap to.
  45172. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45173. */
  45174. snapPositions?: Vector3[];
  45175. /**
  45176. * How close should the teleportation ray be in order to snap to position.
  45177. * Default to 0.8 units (meters)
  45178. */
  45179. snapToPositionRadius?: number;
  45180. /**
  45181. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45182. * If you want to support rotation, make sure your mesh has a direction indicator.
  45183. *
  45184. * When left untouched, the default mesh will be initialized.
  45185. */
  45186. teleportationTargetMesh?: AbstractMesh;
  45187. /**
  45188. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45189. */
  45190. timeToTeleport?: number;
  45191. /**
  45192. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45193. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45194. */
  45195. useMainComponentOnly?: boolean;
  45196. /**
  45197. * Should meshes created here be added to a utility layer or the main scene
  45198. */
  45199. useUtilityLayer?: boolean;
  45200. /**
  45201. * Babylon XR Input class for controller
  45202. */
  45203. xrInput: WebXRInput;
  45204. }
  45205. /**
  45206. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45207. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45208. * the input of the attached controllers.
  45209. */
  45210. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45211. private _options;
  45212. private _controllers;
  45213. private _currentTeleportationControllerId;
  45214. private _floorMeshes;
  45215. private _quadraticBezierCurve;
  45216. private _selectionFeature;
  45217. private _snapToPositions;
  45218. private _snappedToPoint;
  45219. private _teleportationRingMaterial?;
  45220. private _tmpRay;
  45221. private _tmpVector;
  45222. /**
  45223. * The module's name
  45224. */
  45225. static readonly Name: string;
  45226. /**
  45227. * The (Babylon) version of this module.
  45228. * This is an integer representing the implementation version.
  45229. * This number does not correspond to the webxr specs version
  45230. */
  45231. static readonly Version: number;
  45232. /**
  45233. * Is movement backwards enabled
  45234. */
  45235. backwardsMovementEnabled: boolean;
  45236. /**
  45237. * Distance to travel when moving backwards
  45238. */
  45239. backwardsTeleportationDistance: number;
  45240. /**
  45241. * The distance from the user to the inspection point in the direction of the controller
  45242. * A higher number will allow the user to move further
  45243. * defaults to 5 (meters, in xr units)
  45244. */
  45245. parabolicCheckRadius: number;
  45246. /**
  45247. * Should the module support parabolic ray on top of direct ray
  45248. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45249. * Very helpful when moving between floors / different heights
  45250. */
  45251. parabolicRayEnabled: boolean;
  45252. /**
  45253. * How much rotation should be applied when rotating right and left
  45254. */
  45255. rotationAngle: number;
  45256. /**
  45257. * Is rotation enabled when moving forward?
  45258. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45259. */
  45260. rotationEnabled: boolean;
  45261. /**
  45262. * constructs a new anchor system
  45263. * @param _xrSessionManager an instance of WebXRSessionManager
  45264. * @param _options configuration object for this feature
  45265. */
  45266. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45267. /**
  45268. * Get the snapPointsOnly flag
  45269. */
  45270. get snapPointsOnly(): boolean;
  45271. /**
  45272. * Sets the snapPointsOnly flag
  45273. * @param snapToPoints should teleportation be exclusively to snap points
  45274. */
  45275. set snapPointsOnly(snapToPoints: boolean);
  45276. /**
  45277. * Add a new mesh to the floor meshes array
  45278. * @param mesh the mesh to use as floor mesh
  45279. */
  45280. addFloorMesh(mesh: AbstractMesh): void;
  45281. /**
  45282. * Add a new snap-to point to fix teleportation to this position
  45283. * @param newSnapPoint The new Snap-To point
  45284. */
  45285. addSnapPoint(newSnapPoint: Vector3): void;
  45286. attach(): boolean;
  45287. detach(): boolean;
  45288. dispose(): void;
  45289. /**
  45290. * Remove a mesh from the floor meshes array
  45291. * @param mesh the mesh to remove
  45292. */
  45293. removeFloorMesh(mesh: AbstractMesh): void;
  45294. /**
  45295. * Remove a mesh from the floor meshes array using its name
  45296. * @param name the mesh name to remove
  45297. */
  45298. removeFloorMeshByName(name: string): void;
  45299. /**
  45300. * 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
  45301. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45302. * @returns was the point found and removed or not
  45303. */
  45304. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45305. /**
  45306. * This function sets a selection feature that will be disabled when
  45307. * the forward ray is shown and will be reattached when hidden.
  45308. * This is used to remove the selection rays when moving.
  45309. * @param selectionFeature the feature to disable when forward movement is enabled
  45310. */
  45311. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45312. protected _onXRFrame(_xrFrame: XRFrame): void;
  45313. private _attachController;
  45314. private _createDefaultTargetMesh;
  45315. private _detachController;
  45316. private _findClosestSnapPointWithRadius;
  45317. private _setTargetMeshPosition;
  45318. private _setTargetMeshVisibility;
  45319. private _showParabolicPath;
  45320. private _teleportForward;
  45321. }
  45322. }
  45323. declare module BABYLON {
  45324. /**
  45325. * Options for the default xr helper
  45326. */
  45327. export class WebXRDefaultExperienceOptions {
  45328. /**
  45329. * Enable or disable default UI to enter XR
  45330. */
  45331. disableDefaultUI?: boolean;
  45332. /**
  45333. * Should teleportation not initialize. defaults to false.
  45334. */
  45335. disableTeleportation?: boolean;
  45336. /**
  45337. * Floor meshes that will be used for teleport
  45338. */
  45339. floorMeshes?: Array<AbstractMesh>;
  45340. /**
  45341. * If set to true, the first frame will not be used to reset position
  45342. * The first frame is mainly used when copying transformation from the old camera
  45343. * Mainly used in AR
  45344. */
  45345. ignoreNativeCameraTransformation?: boolean;
  45346. /**
  45347. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45348. */
  45349. inputOptions?: IWebXRInputOptions;
  45350. /**
  45351. * optional configuration for the output canvas
  45352. */
  45353. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45354. /**
  45355. * optional UI options. This can be used among other to change session mode and reference space type
  45356. */
  45357. uiOptions?: WebXREnterExitUIOptions;
  45358. /**
  45359. * When loading teleportation and pointer select, use stable versions instead of latest.
  45360. */
  45361. useStablePlugins?: boolean;
  45362. }
  45363. /**
  45364. * Default experience which provides a similar setup to the previous webVRExperience
  45365. */
  45366. export class WebXRDefaultExperience {
  45367. /**
  45368. * Base experience
  45369. */
  45370. baseExperience: WebXRExperienceHelper;
  45371. /**
  45372. * Enables ui for entering/exiting xr
  45373. */
  45374. enterExitUI: WebXREnterExitUI;
  45375. /**
  45376. * Input experience extension
  45377. */
  45378. input: WebXRInput;
  45379. /**
  45380. * Enables laser pointer and selection
  45381. */
  45382. pointerSelection: WebXRControllerPointerSelection;
  45383. /**
  45384. * Default target xr should render to
  45385. */
  45386. renderTarget: WebXRRenderTarget;
  45387. /**
  45388. * Enables teleportation
  45389. */
  45390. teleportation: WebXRMotionControllerTeleportation;
  45391. private constructor();
  45392. /**
  45393. * Creates the default xr experience
  45394. * @param scene scene
  45395. * @param options options for basic configuration
  45396. * @returns resulting WebXRDefaultExperience
  45397. */
  45398. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45399. /**
  45400. * DIsposes of the experience helper
  45401. */
  45402. dispose(): void;
  45403. }
  45404. }
  45405. declare module BABYLON {
  45406. /**
  45407. * Options to modify the vr teleportation behavior.
  45408. */
  45409. export interface VRTeleportationOptions {
  45410. /**
  45411. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45412. */
  45413. floorMeshName?: string;
  45414. /**
  45415. * A list of meshes to be used as the teleportation floor. (default: empty)
  45416. */
  45417. floorMeshes?: Mesh[];
  45418. /**
  45419. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45420. */
  45421. teleportationMode?: number;
  45422. /**
  45423. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45424. */
  45425. teleportationTime?: number;
  45426. /**
  45427. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45428. */
  45429. teleportationSpeed?: number;
  45430. /**
  45431. * The easing function used in the animation or null for Linear. (default CircleEase)
  45432. */
  45433. easingFunction?: EasingFunction;
  45434. }
  45435. /**
  45436. * Options to modify the vr experience helper's behavior.
  45437. */
  45438. export interface VRExperienceHelperOptions extends WebVROptions {
  45439. /**
  45440. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45441. */
  45442. createDeviceOrientationCamera?: boolean;
  45443. /**
  45444. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45445. */
  45446. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45447. /**
  45448. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45449. */
  45450. laserToggle?: boolean;
  45451. /**
  45452. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45453. */
  45454. floorMeshes?: Mesh[];
  45455. /**
  45456. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45457. */
  45458. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45459. /**
  45460. * Defines if WebXR should be used instead of WebVR (if available)
  45461. */
  45462. useXR?: boolean;
  45463. }
  45464. /**
  45465. * Event containing information after VR has been entered
  45466. */
  45467. export class OnAfterEnteringVRObservableEvent {
  45468. /**
  45469. * If entering vr was successful
  45470. */
  45471. success: boolean;
  45472. }
  45473. /**
  45474. * Helps to quickly add VR support to an existing scene.
  45475. * See http://doc.babylonjs.com/how_to/webvr_helper
  45476. */
  45477. export class VRExperienceHelper {
  45478. /** Options to modify the vr experience helper's behavior. */
  45479. webVROptions: VRExperienceHelperOptions;
  45480. private _scene;
  45481. private _position;
  45482. private _btnVR;
  45483. private _btnVRDisplayed;
  45484. private _webVRsupported;
  45485. private _webVRready;
  45486. private _webVRrequesting;
  45487. private _webVRpresenting;
  45488. private _hasEnteredVR;
  45489. private _fullscreenVRpresenting;
  45490. private _inputElement;
  45491. private _webVRCamera;
  45492. private _vrDeviceOrientationCamera;
  45493. private _deviceOrientationCamera;
  45494. private _existingCamera;
  45495. private _onKeyDown;
  45496. private _onVrDisplayPresentChange;
  45497. private _onVRDisplayChanged;
  45498. private _onVRRequestPresentStart;
  45499. private _onVRRequestPresentComplete;
  45500. /**
  45501. * 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)
  45502. */
  45503. enableGazeEvenWhenNoPointerLock: boolean;
  45504. /**
  45505. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45506. */
  45507. exitVROnDoubleTap: boolean;
  45508. /**
  45509. * Observable raised right before entering VR.
  45510. */
  45511. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45512. /**
  45513. * Observable raised when entering VR has completed.
  45514. */
  45515. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45516. /**
  45517. * Observable raised when exiting VR.
  45518. */
  45519. onExitingVRObservable: Observable<VRExperienceHelper>;
  45520. /**
  45521. * Observable raised when controller mesh is loaded.
  45522. */
  45523. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45524. /** Return this.onEnteringVRObservable
  45525. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45526. */
  45527. get onEnteringVR(): Observable<VRExperienceHelper>;
  45528. /** Return this.onExitingVRObservable
  45529. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45530. */
  45531. get onExitingVR(): Observable<VRExperienceHelper>;
  45532. /** Return this.onControllerMeshLoadedObservable
  45533. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45534. */
  45535. get onControllerMeshLoaded(): Observable<WebVRController>;
  45536. private _rayLength;
  45537. private _useCustomVRButton;
  45538. private _teleportationRequested;
  45539. private _teleportActive;
  45540. private _floorMeshName;
  45541. private _floorMeshesCollection;
  45542. private _teleportationMode;
  45543. private _teleportationTime;
  45544. private _teleportationSpeed;
  45545. private _teleportationEasing;
  45546. private _rotationAllowed;
  45547. private _teleportBackwardsVector;
  45548. private _teleportationTarget;
  45549. private _isDefaultTeleportationTarget;
  45550. private _postProcessMove;
  45551. private _teleportationFillColor;
  45552. private _teleportationBorderColor;
  45553. private _rotationAngle;
  45554. private _haloCenter;
  45555. private _cameraGazer;
  45556. private _padSensibilityUp;
  45557. private _padSensibilityDown;
  45558. private _leftController;
  45559. private _rightController;
  45560. private _gazeColor;
  45561. private _laserColor;
  45562. private _pickedLaserColor;
  45563. private _pickedGazeColor;
  45564. /**
  45565. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45566. */
  45567. onNewMeshSelected: Observable<AbstractMesh>;
  45568. /**
  45569. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45570. * This observable will provide the mesh and the controller used to select the mesh
  45571. */
  45572. onMeshSelectedWithController: Observable<{
  45573. mesh: AbstractMesh;
  45574. controller: WebVRController;
  45575. }>;
  45576. /**
  45577. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45578. */
  45579. onNewMeshPicked: Observable<PickingInfo>;
  45580. private _circleEase;
  45581. /**
  45582. * Observable raised before camera teleportation
  45583. */
  45584. onBeforeCameraTeleport: Observable<Vector3>;
  45585. /**
  45586. * Observable raised after camera teleportation
  45587. */
  45588. onAfterCameraTeleport: Observable<Vector3>;
  45589. /**
  45590. * Observable raised when current selected mesh gets unselected
  45591. */
  45592. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45593. private _raySelectionPredicate;
  45594. /**
  45595. * To be optionaly changed by user to define custom ray selection
  45596. */
  45597. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45598. /**
  45599. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45600. */
  45601. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45602. /**
  45603. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45604. */
  45605. teleportationEnabled: boolean;
  45606. private _defaultHeight;
  45607. private _teleportationInitialized;
  45608. private _interactionsEnabled;
  45609. private _interactionsRequested;
  45610. private _displayGaze;
  45611. private _displayLaserPointer;
  45612. /**
  45613. * The mesh used to display where the user is going to teleport.
  45614. */
  45615. get teleportationTarget(): Mesh;
  45616. /**
  45617. * Sets the mesh to be used to display where the user is going to teleport.
  45618. */
  45619. set teleportationTarget(value: Mesh);
  45620. /**
  45621. * 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
  45622. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45623. * See http://doc.babylonjs.com/resources/baking_transformations
  45624. */
  45625. get gazeTrackerMesh(): Mesh;
  45626. set gazeTrackerMesh(value: Mesh);
  45627. /**
  45628. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45629. */
  45630. updateGazeTrackerScale: boolean;
  45631. /**
  45632. * If the gaze trackers color should be updated when selecting meshes
  45633. */
  45634. updateGazeTrackerColor: boolean;
  45635. /**
  45636. * If the controller laser color should be updated when selecting meshes
  45637. */
  45638. updateControllerLaserColor: boolean;
  45639. /**
  45640. * The gaze tracking mesh corresponding to the left controller
  45641. */
  45642. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45643. /**
  45644. * The gaze tracking mesh corresponding to the right controller
  45645. */
  45646. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45647. /**
  45648. * If the ray of the gaze should be displayed.
  45649. */
  45650. get displayGaze(): boolean;
  45651. /**
  45652. * Sets if the ray of the gaze should be displayed.
  45653. */
  45654. set displayGaze(value: boolean);
  45655. /**
  45656. * If the ray of the LaserPointer should be displayed.
  45657. */
  45658. get displayLaserPointer(): boolean;
  45659. /**
  45660. * Sets if the ray of the LaserPointer should be displayed.
  45661. */
  45662. set displayLaserPointer(value: boolean);
  45663. /**
  45664. * The deviceOrientationCamera used as the camera when not in VR.
  45665. */
  45666. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45667. /**
  45668. * Based on the current WebVR support, returns the current VR camera used.
  45669. */
  45670. get currentVRCamera(): Nullable<Camera>;
  45671. /**
  45672. * The webVRCamera which is used when in VR.
  45673. */
  45674. get webVRCamera(): WebVRFreeCamera;
  45675. /**
  45676. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45677. */
  45678. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45679. /**
  45680. * The html button that is used to trigger entering into VR.
  45681. */
  45682. get vrButton(): Nullable<HTMLButtonElement>;
  45683. private get _teleportationRequestInitiated();
  45684. /**
  45685. * Defines whether or not Pointer lock should be requested when switching to
  45686. * full screen.
  45687. */
  45688. requestPointerLockOnFullScreen: boolean;
  45689. /**
  45690. * If asking to force XR, this will be populated with the default xr experience
  45691. */
  45692. xr: WebXRDefaultExperience;
  45693. /**
  45694. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45695. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45696. */
  45697. xrTestDone: boolean;
  45698. /**
  45699. * Instantiates a VRExperienceHelper.
  45700. * Helps to quickly add VR support to an existing scene.
  45701. * @param scene The scene the VRExperienceHelper belongs to.
  45702. * @param webVROptions Options to modify the vr experience helper's behavior.
  45703. */
  45704. constructor(scene: Scene,
  45705. /** Options to modify the vr experience helper's behavior. */
  45706. webVROptions?: VRExperienceHelperOptions);
  45707. private completeVRInit;
  45708. private _onDefaultMeshLoaded;
  45709. private _onResize;
  45710. private _onFullscreenChange;
  45711. /**
  45712. * Gets a value indicating if we are currently in VR mode.
  45713. */
  45714. get isInVRMode(): boolean;
  45715. private onVrDisplayPresentChange;
  45716. private onVRDisplayChanged;
  45717. private moveButtonToBottomRight;
  45718. private displayVRButton;
  45719. private updateButtonVisibility;
  45720. private _cachedAngularSensibility;
  45721. /**
  45722. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45723. * Otherwise, will use the fullscreen API.
  45724. */
  45725. enterVR(): void;
  45726. /**
  45727. * Attempt to exit VR, or fullscreen.
  45728. */
  45729. exitVR(): void;
  45730. /**
  45731. * The position of the vr experience helper.
  45732. */
  45733. get position(): Vector3;
  45734. /**
  45735. * Sets the position of the vr experience helper.
  45736. */
  45737. set position(value: Vector3);
  45738. /**
  45739. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45740. */
  45741. enableInteractions(): void;
  45742. private get _noControllerIsActive();
  45743. private beforeRender;
  45744. private _isTeleportationFloor;
  45745. /**
  45746. * Adds a floor mesh to be used for teleportation.
  45747. * @param floorMesh the mesh to be used for teleportation.
  45748. */
  45749. addFloorMesh(floorMesh: Mesh): void;
  45750. /**
  45751. * Removes a floor mesh from being used for teleportation.
  45752. * @param floorMesh the mesh to be removed.
  45753. */
  45754. removeFloorMesh(floorMesh: Mesh): void;
  45755. /**
  45756. * Enables interactions and teleportation using the VR controllers and gaze.
  45757. * @param vrTeleportationOptions options to modify teleportation behavior.
  45758. */
  45759. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45760. private _onNewGamepadConnected;
  45761. private _tryEnableInteractionOnController;
  45762. private _onNewGamepadDisconnected;
  45763. private _enableInteractionOnController;
  45764. private _checkTeleportWithRay;
  45765. private _checkRotate;
  45766. private _checkTeleportBackwards;
  45767. private _enableTeleportationOnController;
  45768. private _createTeleportationCircles;
  45769. private _displayTeleportationTarget;
  45770. private _hideTeleportationTarget;
  45771. private _rotateCamera;
  45772. private _moveTeleportationSelectorTo;
  45773. private _workingVector;
  45774. private _workingQuaternion;
  45775. private _workingMatrix;
  45776. /**
  45777. * Time Constant Teleportation Mode
  45778. */
  45779. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45780. /**
  45781. * Speed Constant Teleportation Mode
  45782. */
  45783. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45784. /**
  45785. * Teleports the users feet to the desired location
  45786. * @param location The location where the user's feet should be placed
  45787. */
  45788. teleportCamera(location: Vector3): void;
  45789. private _convertNormalToDirectionOfRay;
  45790. private _castRayAndSelectObject;
  45791. private _notifySelectedMeshUnselected;
  45792. /**
  45793. * Permanently set new colors for the laser pointer
  45794. * @param color the new laser color
  45795. * @param pickedColor the new laser color when picked mesh detected
  45796. */
  45797. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45798. /**
  45799. * Set lighting enabled / disabled on the laser pointer of both controllers
  45800. * @param enabled should the lighting be enabled on the laser pointer
  45801. */
  45802. setLaserLightingState(enabled?: boolean): void;
  45803. /**
  45804. * Permanently set new colors for the gaze pointer
  45805. * @param color the new gaze color
  45806. * @param pickedColor the new gaze color when picked mesh detected
  45807. */
  45808. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45809. /**
  45810. * Sets the color of the laser ray from the vr controllers.
  45811. * @param color new color for the ray.
  45812. */
  45813. changeLaserColor(color: Color3): void;
  45814. /**
  45815. * Sets the color of the ray from the vr headsets gaze.
  45816. * @param color new color for the ray.
  45817. */
  45818. changeGazeColor(color: Color3): void;
  45819. /**
  45820. * Exits VR and disposes of the vr experience helper
  45821. */
  45822. dispose(): void;
  45823. /**
  45824. * Gets the name of the VRExperienceHelper class
  45825. * @returns "VRExperienceHelper"
  45826. */
  45827. getClassName(): string;
  45828. }
  45829. }
  45830. declare module BABYLON {
  45831. /**
  45832. * Contains an array of blocks representing the octree
  45833. */
  45834. export interface IOctreeContainer<T> {
  45835. /**
  45836. * Blocks within the octree
  45837. */
  45838. blocks: Array<OctreeBlock<T>>;
  45839. }
  45840. /**
  45841. * Class used to store a cell in an octree
  45842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45843. */
  45844. export class OctreeBlock<T> {
  45845. /**
  45846. * Gets the content of the current block
  45847. */
  45848. entries: T[];
  45849. /**
  45850. * Gets the list of block children
  45851. */
  45852. blocks: Array<OctreeBlock<T>>;
  45853. private _depth;
  45854. private _maxDepth;
  45855. private _capacity;
  45856. private _minPoint;
  45857. private _maxPoint;
  45858. private _boundingVectors;
  45859. private _creationFunc;
  45860. /**
  45861. * Creates a new block
  45862. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45863. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45864. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45865. * @param depth defines the current depth of this block in the octree
  45866. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45867. * @param creationFunc defines a callback to call when an element is added to the block
  45868. */
  45869. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45870. /**
  45871. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45872. */
  45873. get capacity(): number;
  45874. /**
  45875. * Gets the minimum vector (in world space) of the block's bounding box
  45876. */
  45877. get minPoint(): Vector3;
  45878. /**
  45879. * Gets the maximum vector (in world space) of the block's bounding box
  45880. */
  45881. get maxPoint(): Vector3;
  45882. /**
  45883. * Add a new element to this block
  45884. * @param entry defines the element to add
  45885. */
  45886. addEntry(entry: T): void;
  45887. /**
  45888. * Remove an element from this block
  45889. * @param entry defines the element to remove
  45890. */
  45891. removeEntry(entry: T): void;
  45892. /**
  45893. * Add an array of elements to this block
  45894. * @param entries defines the array of elements to add
  45895. */
  45896. addEntries(entries: T[]): void;
  45897. /**
  45898. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45899. * @param frustumPlanes defines the frustum planes to test
  45900. * @param selection defines the array to store current content if selection is positive
  45901. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45902. */
  45903. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45904. /**
  45905. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45906. * @param sphereCenter defines the bounding sphere center
  45907. * @param sphereRadius defines the bounding sphere radius
  45908. * @param selection defines the array to store current content if selection is positive
  45909. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45910. */
  45911. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45912. /**
  45913. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45914. * @param ray defines the ray to test with
  45915. * @param selection defines the array to store current content if selection is positive
  45916. */
  45917. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45918. /**
  45919. * Subdivide the content into child blocks (this block will then be empty)
  45920. */
  45921. createInnerBlocks(): void;
  45922. /**
  45923. * @hidden
  45924. */
  45925. 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;
  45926. }
  45927. }
  45928. declare module BABYLON {
  45929. /**
  45930. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45931. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45932. */
  45933. export class Octree<T> {
  45934. /** 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.) */
  45935. maxDepth: number;
  45936. /**
  45937. * Blocks within the octree containing objects
  45938. */
  45939. blocks: Array<OctreeBlock<T>>;
  45940. /**
  45941. * Content stored in the octree
  45942. */
  45943. dynamicContent: T[];
  45944. private _maxBlockCapacity;
  45945. private _selectionContent;
  45946. private _creationFunc;
  45947. /**
  45948. * Creates a octree
  45949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45950. * @param creationFunc function to be used to instatiate the octree
  45951. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45952. * @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.)
  45953. */
  45954. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45955. /** 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.) */
  45956. maxDepth?: number);
  45957. /**
  45958. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45959. * @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);
  45960. * @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);
  45961. * @param entries meshes to be added to the octree blocks
  45962. */
  45963. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45964. /**
  45965. * Adds a mesh to the octree
  45966. * @param entry Mesh to add to the octree
  45967. */
  45968. addMesh(entry: T): void;
  45969. /**
  45970. * Remove an element from the octree
  45971. * @param entry defines the element to remove
  45972. */
  45973. removeMesh(entry: T): void;
  45974. /**
  45975. * Selects an array of meshes within the frustum
  45976. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45977. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45978. * @returns array of meshes within the frustum
  45979. */
  45980. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45981. /**
  45982. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45983. * @param sphereCenter defines the bounding sphere center
  45984. * @param sphereRadius defines the bounding sphere radius
  45985. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45986. * @returns an array of objects that intersect the sphere
  45987. */
  45988. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45989. /**
  45990. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45991. * @param ray defines the ray to test with
  45992. * @returns array of intersected objects
  45993. */
  45994. intersectsRay(ray: Ray): SmartArray<T>;
  45995. /**
  45996. * Adds a mesh into the octree block if it intersects the block
  45997. */
  45998. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45999. /**
  46000. * Adds a submesh into the octree block if it intersects the block
  46001. */
  46002. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46003. }
  46004. }
  46005. declare module BABYLON {
  46006. interface Scene {
  46007. /**
  46008. * @hidden
  46009. * Backing Filed
  46010. */
  46011. _selectionOctree: Octree<AbstractMesh>;
  46012. /**
  46013. * Gets the octree used to boost mesh selection (picking)
  46014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46015. */
  46016. selectionOctree: Octree<AbstractMesh>;
  46017. /**
  46018. * Creates or updates the octree used to boost selection (picking)
  46019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46020. * @param maxCapacity defines the maximum capacity per leaf
  46021. * @param maxDepth defines the maximum depth of the octree
  46022. * @returns an octree of AbstractMesh
  46023. */
  46024. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46025. }
  46026. interface AbstractMesh {
  46027. /**
  46028. * @hidden
  46029. * Backing Field
  46030. */
  46031. _submeshesOctree: Octree<SubMesh>;
  46032. /**
  46033. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46034. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46035. * @param maxCapacity defines the maximum size of each block (64 by default)
  46036. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46037. * @returns the new octree
  46038. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46040. */
  46041. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46042. }
  46043. /**
  46044. * Defines the octree scene component responsible to manage any octrees
  46045. * in a given scene.
  46046. */
  46047. export class OctreeSceneComponent {
  46048. /**
  46049. * The component name help to identify the component in the list of scene components.
  46050. */
  46051. readonly name: string;
  46052. /**
  46053. * The scene the component belongs to.
  46054. */
  46055. scene: Scene;
  46056. /**
  46057. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46058. */
  46059. readonly checksIsEnabled: boolean;
  46060. /**
  46061. * Creates a new instance of the component for the given scene
  46062. * @param scene Defines the scene to register the component in
  46063. */
  46064. constructor(scene: Scene);
  46065. /**
  46066. * Registers the component in a given scene
  46067. */
  46068. register(): void;
  46069. /**
  46070. * Return the list of active meshes
  46071. * @returns the list of active meshes
  46072. */
  46073. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46074. /**
  46075. * Return the list of active sub meshes
  46076. * @param mesh The mesh to get the candidates sub meshes from
  46077. * @returns the list of active sub meshes
  46078. */
  46079. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46080. private _tempRay;
  46081. /**
  46082. * Return the list of sub meshes intersecting with a given local ray
  46083. * @param mesh defines the mesh to find the submesh for
  46084. * @param localRay defines the ray in local space
  46085. * @returns the list of intersecting sub meshes
  46086. */
  46087. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46088. /**
  46089. * Return the list of sub meshes colliding with a collider
  46090. * @param mesh defines the mesh to find the submesh for
  46091. * @param collider defines the collider to evaluate the collision against
  46092. * @returns the list of colliding sub meshes
  46093. */
  46094. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46095. /**
  46096. * Rebuilds the elements related to this component in case of
  46097. * context lost for instance.
  46098. */
  46099. rebuild(): void;
  46100. /**
  46101. * Disposes the component and the associated ressources.
  46102. */
  46103. dispose(): void;
  46104. }
  46105. }
  46106. declare module BABYLON {
  46107. /**
  46108. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46109. */
  46110. export class Gizmo implements IDisposable {
  46111. /** The utility layer the gizmo will be added to */
  46112. gizmoLayer: UtilityLayerRenderer;
  46113. /**
  46114. * The root mesh of the gizmo
  46115. */
  46116. _rootMesh: Mesh;
  46117. private _attachedMesh;
  46118. /**
  46119. * Ratio for the scale of the gizmo (Default: 1)
  46120. */
  46121. scaleRatio: number;
  46122. /**
  46123. * If a custom mesh has been set (Default: false)
  46124. */
  46125. protected _customMeshSet: boolean;
  46126. /**
  46127. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46128. * * When set, interactions will be enabled
  46129. */
  46130. get attachedMesh(): Nullable<AbstractMesh>;
  46131. set attachedMesh(value: Nullable<AbstractMesh>);
  46132. /**
  46133. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46134. * @param mesh The mesh to replace the default mesh of the gizmo
  46135. */
  46136. setCustomMesh(mesh: Mesh): void;
  46137. /**
  46138. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46139. */
  46140. updateGizmoRotationToMatchAttachedMesh: boolean;
  46141. /**
  46142. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46143. */
  46144. updateGizmoPositionToMatchAttachedMesh: boolean;
  46145. /**
  46146. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46147. */
  46148. updateScale: boolean;
  46149. protected _interactionsEnabled: boolean;
  46150. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46151. private _beforeRenderObserver;
  46152. private _tempVector;
  46153. /**
  46154. * Creates a gizmo
  46155. * @param gizmoLayer The utility layer the gizmo will be added to
  46156. */
  46157. constructor(
  46158. /** The utility layer the gizmo will be added to */
  46159. gizmoLayer?: UtilityLayerRenderer);
  46160. /**
  46161. * Updates the gizmo to match the attached mesh's position/rotation
  46162. */
  46163. protected _update(): void;
  46164. /**
  46165. * Disposes of the gizmo
  46166. */
  46167. dispose(): void;
  46168. }
  46169. }
  46170. declare module BABYLON {
  46171. /**
  46172. * Single plane drag gizmo
  46173. */
  46174. export class PlaneDragGizmo extends Gizmo {
  46175. /**
  46176. * Drag behavior responsible for the gizmos dragging interactions
  46177. */
  46178. dragBehavior: PointerDragBehavior;
  46179. private _pointerObserver;
  46180. /**
  46181. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46182. */
  46183. snapDistance: number;
  46184. /**
  46185. * Event that fires each time the gizmo snaps to a new location.
  46186. * * snapDistance is the the change in distance
  46187. */
  46188. onSnapObservable: Observable<{
  46189. snapDistance: number;
  46190. }>;
  46191. private _plane;
  46192. private _coloredMaterial;
  46193. private _hoverMaterial;
  46194. private _isEnabled;
  46195. private _parent;
  46196. /** @hidden */
  46197. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46198. /** @hidden */
  46199. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46200. /**
  46201. * Creates a PlaneDragGizmo
  46202. * @param gizmoLayer The utility layer the gizmo will be added to
  46203. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46204. * @param color The color of the gizmo
  46205. */
  46206. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46207. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46208. /**
  46209. * If the gizmo is enabled
  46210. */
  46211. set isEnabled(value: boolean);
  46212. get isEnabled(): boolean;
  46213. /**
  46214. * Disposes of the gizmo
  46215. */
  46216. dispose(): void;
  46217. }
  46218. }
  46219. declare module BABYLON {
  46220. /**
  46221. * Gizmo that enables dragging a mesh along 3 axis
  46222. */
  46223. export class PositionGizmo extends Gizmo {
  46224. /**
  46225. * Internal gizmo used for interactions on the x axis
  46226. */
  46227. xGizmo: AxisDragGizmo;
  46228. /**
  46229. * Internal gizmo used for interactions on the y axis
  46230. */
  46231. yGizmo: AxisDragGizmo;
  46232. /**
  46233. * Internal gizmo used for interactions on the z axis
  46234. */
  46235. zGizmo: AxisDragGizmo;
  46236. /**
  46237. * Internal gizmo used for interactions on the yz plane
  46238. */
  46239. xPlaneGizmo: PlaneDragGizmo;
  46240. /**
  46241. * Internal gizmo used for interactions on the xz plane
  46242. */
  46243. yPlaneGizmo: PlaneDragGizmo;
  46244. /**
  46245. * Internal gizmo used for interactions on the xy plane
  46246. */
  46247. zPlaneGizmo: PlaneDragGizmo;
  46248. /**
  46249. * private variables
  46250. */
  46251. private _meshAttached;
  46252. private _updateGizmoRotationToMatchAttachedMesh;
  46253. private _snapDistance;
  46254. private _scaleRatio;
  46255. /** Fires an event when any of it's sub gizmos are dragged */
  46256. onDragStartObservable: Observable<unknown>;
  46257. /** Fires an event when any of it's sub gizmos are released from dragging */
  46258. onDragEndObservable: Observable<unknown>;
  46259. /**
  46260. * If set to true, planar drag is enabled
  46261. */
  46262. private _planarGizmoEnabled;
  46263. get attachedMesh(): Nullable<AbstractMesh>;
  46264. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46265. /**
  46266. * Creates a PositionGizmo
  46267. * @param gizmoLayer The utility layer the gizmo will be added to
  46268. */
  46269. constructor(gizmoLayer?: UtilityLayerRenderer);
  46270. /**
  46271. * If the planar drag gizmo is enabled
  46272. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46273. */
  46274. set planarGizmoEnabled(value: boolean);
  46275. get planarGizmoEnabled(): boolean;
  46276. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46277. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46278. /**
  46279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46280. */
  46281. set snapDistance(value: number);
  46282. get snapDistance(): number;
  46283. /**
  46284. * Ratio for the scale of the gizmo (Default: 1)
  46285. */
  46286. set scaleRatio(value: number);
  46287. get scaleRatio(): number;
  46288. /**
  46289. * Disposes of the gizmo
  46290. */
  46291. dispose(): void;
  46292. /**
  46293. * CustomMeshes are not supported by this gizmo
  46294. * @param mesh The mesh to replace the default mesh of the gizmo
  46295. */
  46296. setCustomMesh(mesh: Mesh): void;
  46297. }
  46298. }
  46299. declare module BABYLON {
  46300. /**
  46301. * Single axis drag gizmo
  46302. */
  46303. export class AxisDragGizmo extends Gizmo {
  46304. /**
  46305. * Drag behavior responsible for the gizmos dragging interactions
  46306. */
  46307. dragBehavior: PointerDragBehavior;
  46308. private _pointerObserver;
  46309. /**
  46310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46311. */
  46312. snapDistance: number;
  46313. /**
  46314. * Event that fires each time the gizmo snaps to a new location.
  46315. * * snapDistance is the the change in distance
  46316. */
  46317. onSnapObservable: Observable<{
  46318. snapDistance: number;
  46319. }>;
  46320. private _isEnabled;
  46321. private _parent;
  46322. private _arrow;
  46323. private _coloredMaterial;
  46324. private _hoverMaterial;
  46325. /** @hidden */
  46326. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46327. /** @hidden */
  46328. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46329. /**
  46330. * Creates an AxisDragGizmo
  46331. * @param gizmoLayer The utility layer the gizmo will be added to
  46332. * @param dragAxis The axis which the gizmo will be able to drag on
  46333. * @param color The color of the gizmo
  46334. */
  46335. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46336. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46337. /**
  46338. * If the gizmo is enabled
  46339. */
  46340. set isEnabled(value: boolean);
  46341. get isEnabled(): boolean;
  46342. /**
  46343. * Disposes of the gizmo
  46344. */
  46345. dispose(): void;
  46346. }
  46347. }
  46348. declare module BABYLON.Debug {
  46349. /**
  46350. * The Axes viewer will show 3 axes in a specific point in space
  46351. */
  46352. export class AxesViewer {
  46353. private _xAxis;
  46354. private _yAxis;
  46355. private _zAxis;
  46356. private _scaleLinesFactor;
  46357. private _instanced;
  46358. /**
  46359. * Gets the hosting scene
  46360. */
  46361. scene: Scene;
  46362. /**
  46363. * Gets or sets a number used to scale line length
  46364. */
  46365. scaleLines: number;
  46366. /** Gets the node hierarchy used to render x-axis */
  46367. get xAxis(): TransformNode;
  46368. /** Gets the node hierarchy used to render y-axis */
  46369. get yAxis(): TransformNode;
  46370. /** Gets the node hierarchy used to render z-axis */
  46371. get zAxis(): TransformNode;
  46372. /**
  46373. * Creates a new AxesViewer
  46374. * @param scene defines the hosting scene
  46375. * @param scaleLines defines a number used to scale line length (1 by default)
  46376. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46377. * @param xAxis defines the node hierarchy used to render the x-axis
  46378. * @param yAxis defines the node hierarchy used to render the y-axis
  46379. * @param zAxis defines the node hierarchy used to render the z-axis
  46380. */
  46381. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46382. /**
  46383. * Force the viewer to update
  46384. * @param position defines the position of the viewer
  46385. * @param xaxis defines the x axis of the viewer
  46386. * @param yaxis defines the y axis of the viewer
  46387. * @param zaxis defines the z axis of the viewer
  46388. */
  46389. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46390. /**
  46391. * Creates an instance of this axes viewer.
  46392. * @returns a new axes viewer with instanced meshes
  46393. */
  46394. createInstance(): AxesViewer;
  46395. /** Releases resources */
  46396. dispose(): void;
  46397. private static _SetRenderingGroupId;
  46398. }
  46399. }
  46400. declare module BABYLON.Debug {
  46401. /**
  46402. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46403. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46404. */
  46405. export class BoneAxesViewer extends AxesViewer {
  46406. /**
  46407. * Gets or sets the target mesh where to display the axes viewer
  46408. */
  46409. mesh: Nullable<Mesh>;
  46410. /**
  46411. * Gets or sets the target bone where to display the axes viewer
  46412. */
  46413. bone: Nullable<Bone>;
  46414. /** Gets current position */
  46415. pos: Vector3;
  46416. /** Gets direction of X axis */
  46417. xaxis: Vector3;
  46418. /** Gets direction of Y axis */
  46419. yaxis: Vector3;
  46420. /** Gets direction of Z axis */
  46421. zaxis: Vector3;
  46422. /**
  46423. * Creates a new BoneAxesViewer
  46424. * @param scene defines the hosting scene
  46425. * @param bone defines the target bone
  46426. * @param mesh defines the target mesh
  46427. * @param scaleLines defines a scaling factor for line length (1 by default)
  46428. */
  46429. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46430. /**
  46431. * Force the viewer to update
  46432. */
  46433. update(): void;
  46434. /** Releases resources */
  46435. dispose(): void;
  46436. }
  46437. }
  46438. declare module BABYLON {
  46439. /**
  46440. * Interface used to define scene explorer extensibility option
  46441. */
  46442. export interface IExplorerExtensibilityOption {
  46443. /**
  46444. * Define the option label
  46445. */
  46446. label: string;
  46447. /**
  46448. * Defines the action to execute on click
  46449. */
  46450. action: (entity: any) => void;
  46451. }
  46452. /**
  46453. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46454. */
  46455. export interface IExplorerExtensibilityGroup {
  46456. /**
  46457. * Defines a predicate to test if a given type mut be extended
  46458. */
  46459. predicate: (entity: any) => boolean;
  46460. /**
  46461. * Gets the list of options added to a type
  46462. */
  46463. entries: IExplorerExtensibilityOption[];
  46464. }
  46465. /**
  46466. * Interface used to define the options to use to create the Inspector
  46467. */
  46468. export interface IInspectorOptions {
  46469. /**
  46470. * Display in overlay mode (default: false)
  46471. */
  46472. overlay?: boolean;
  46473. /**
  46474. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46475. */
  46476. globalRoot?: HTMLElement;
  46477. /**
  46478. * Display the Scene explorer
  46479. */
  46480. showExplorer?: boolean;
  46481. /**
  46482. * Display the property inspector
  46483. */
  46484. showInspector?: boolean;
  46485. /**
  46486. * Display in embed mode (both panes on the right)
  46487. */
  46488. embedMode?: boolean;
  46489. /**
  46490. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46491. */
  46492. handleResize?: boolean;
  46493. /**
  46494. * Allow the panes to popup (default: true)
  46495. */
  46496. enablePopup?: boolean;
  46497. /**
  46498. * Allow the panes to be closed by users (default: true)
  46499. */
  46500. enableClose?: boolean;
  46501. /**
  46502. * Optional list of extensibility entries
  46503. */
  46504. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46505. /**
  46506. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46507. */
  46508. inspectorURL?: string;
  46509. /**
  46510. * Optional initial tab (default to DebugLayerTab.Properties)
  46511. */
  46512. initialTab?: DebugLayerTab;
  46513. }
  46514. interface Scene {
  46515. /**
  46516. * @hidden
  46517. * Backing field
  46518. */
  46519. _debugLayer: DebugLayer;
  46520. /**
  46521. * Gets the debug layer (aka Inspector) associated with the scene
  46522. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46523. */
  46524. debugLayer: DebugLayer;
  46525. }
  46526. /**
  46527. * Enum of inspector action tab
  46528. */
  46529. export enum DebugLayerTab {
  46530. /**
  46531. * Properties tag (default)
  46532. */
  46533. Properties = 0,
  46534. /**
  46535. * Debug tab
  46536. */
  46537. Debug = 1,
  46538. /**
  46539. * Statistics tab
  46540. */
  46541. Statistics = 2,
  46542. /**
  46543. * Tools tab
  46544. */
  46545. Tools = 3,
  46546. /**
  46547. * Settings tab
  46548. */
  46549. Settings = 4
  46550. }
  46551. /**
  46552. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46553. * what is happening in your scene
  46554. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46555. */
  46556. export class DebugLayer {
  46557. /**
  46558. * Define the url to get the inspector script from.
  46559. * By default it uses the babylonjs CDN.
  46560. * @ignoreNaming
  46561. */
  46562. static InspectorURL: string;
  46563. private _scene;
  46564. private BJSINSPECTOR;
  46565. private _onPropertyChangedObservable?;
  46566. /**
  46567. * Observable triggered when a property is changed through the inspector.
  46568. */
  46569. get onPropertyChangedObservable(): any;
  46570. /**
  46571. * Instantiates a new debug layer.
  46572. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46573. * what is happening in your scene
  46574. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46575. * @param scene Defines the scene to inspect
  46576. */
  46577. constructor(scene: Scene);
  46578. /** Creates the inspector window. */
  46579. private _createInspector;
  46580. /**
  46581. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46582. * @param entity defines the entity to select
  46583. * @param lineContainerTitle defines the specific block to highlight
  46584. */
  46585. select(entity: any, lineContainerTitle?: string): void;
  46586. /** Get the inspector from bundle or global */
  46587. private _getGlobalInspector;
  46588. /**
  46589. * Get if the inspector is visible or not.
  46590. * @returns true if visible otherwise, false
  46591. */
  46592. isVisible(): boolean;
  46593. /**
  46594. * Hide the inspector and close its window.
  46595. */
  46596. hide(): void;
  46597. /**
  46598. * Launch the debugLayer.
  46599. * @param config Define the configuration of the inspector
  46600. * @return a promise fulfilled when the debug layer is visible
  46601. */
  46602. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46603. }
  46604. }
  46605. declare module BABYLON {
  46606. /**
  46607. * Class containing static functions to help procedurally build meshes
  46608. */
  46609. export class BoxBuilder {
  46610. /**
  46611. * Creates a box mesh
  46612. * * The parameter `size` sets the size (float) of each box side (default 1)
  46613. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46614. * * 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)
  46615. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46617. * * 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
  46618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46619. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46620. * @param name defines the name of the mesh
  46621. * @param options defines the options used to create the mesh
  46622. * @param scene defines the hosting scene
  46623. * @returns the box mesh
  46624. */
  46625. static CreateBox(name: string, options: {
  46626. size?: number;
  46627. width?: number;
  46628. height?: number;
  46629. depth?: number;
  46630. faceUV?: Vector4[];
  46631. faceColors?: Color4[];
  46632. sideOrientation?: number;
  46633. frontUVs?: Vector4;
  46634. backUVs?: Vector4;
  46635. wrap?: boolean;
  46636. topBaseAt?: number;
  46637. bottomBaseAt?: number;
  46638. updatable?: boolean;
  46639. }, scene?: Nullable<Scene>): Mesh;
  46640. }
  46641. }
  46642. declare module BABYLON.Debug {
  46643. /**
  46644. * Used to show the physics impostor around the specific mesh
  46645. */
  46646. export class PhysicsViewer {
  46647. /** @hidden */
  46648. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46649. /** @hidden */
  46650. protected _meshes: Array<Nullable<AbstractMesh>>;
  46651. /** @hidden */
  46652. protected _scene: Nullable<Scene>;
  46653. /** @hidden */
  46654. protected _numMeshes: number;
  46655. /** @hidden */
  46656. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46657. private _renderFunction;
  46658. private _utilityLayer;
  46659. private _debugBoxMesh;
  46660. private _debugSphereMesh;
  46661. private _debugCylinderMesh;
  46662. private _debugMaterial;
  46663. private _debugMeshMeshes;
  46664. /**
  46665. * Creates a new PhysicsViewer
  46666. * @param scene defines the hosting scene
  46667. */
  46668. constructor(scene: Scene);
  46669. /** @hidden */
  46670. protected _updateDebugMeshes(): void;
  46671. /**
  46672. * Renders a specified physic impostor
  46673. * @param impostor defines the impostor to render
  46674. * @param targetMesh defines the mesh represented by the impostor
  46675. * @returns the new debug mesh used to render the impostor
  46676. */
  46677. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46678. /**
  46679. * Hides a specified physic impostor
  46680. * @param impostor defines the impostor to hide
  46681. */
  46682. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46683. private _getDebugMaterial;
  46684. private _getDebugBoxMesh;
  46685. private _getDebugSphereMesh;
  46686. private _getDebugCylinderMesh;
  46687. private _getDebugMeshMesh;
  46688. private _getDebugMesh;
  46689. /** Releases all resources */
  46690. dispose(): void;
  46691. }
  46692. }
  46693. declare module BABYLON {
  46694. /**
  46695. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46696. * in order to better appreciate the issue one might have.
  46697. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46698. */
  46699. export class RayHelper {
  46700. /**
  46701. * Defines the ray we are currently tryin to visualize.
  46702. */
  46703. ray: Nullable<Ray>;
  46704. private _renderPoints;
  46705. private _renderLine;
  46706. private _renderFunction;
  46707. private _scene;
  46708. private _updateToMeshFunction;
  46709. private _attachedToMesh;
  46710. private _meshSpaceDirection;
  46711. private _meshSpaceOrigin;
  46712. /**
  46713. * Helper function to create a colored helper in a scene in one line.
  46714. * @param ray Defines the ray we are currently tryin to visualize
  46715. * @param scene Defines the scene the ray is used in
  46716. * @param color Defines the color we want to see the ray in
  46717. * @returns The newly created ray helper.
  46718. */
  46719. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46720. /**
  46721. * Instantiate a new ray helper.
  46722. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46723. * in order to better appreciate the issue one might have.
  46724. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46725. * @param ray Defines the ray we are currently tryin to visualize
  46726. */
  46727. constructor(ray: Ray);
  46728. /**
  46729. * Shows the ray we are willing to debug.
  46730. * @param scene Defines the scene the ray needs to be rendered in
  46731. * @param color Defines the color the ray needs to be rendered in
  46732. */
  46733. show(scene: Scene, color?: Color3): void;
  46734. /**
  46735. * Hides the ray we are debugging.
  46736. */
  46737. hide(): void;
  46738. private _render;
  46739. /**
  46740. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46741. * @param mesh Defines the mesh we want the helper attached to
  46742. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46743. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46744. * @param length Defines the length of the ray
  46745. */
  46746. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46747. /**
  46748. * Detach the ray helper from the mesh it has previously been attached to.
  46749. */
  46750. detachFromMesh(): void;
  46751. private _updateToMesh;
  46752. /**
  46753. * Dispose the helper and release its associated resources.
  46754. */
  46755. dispose(): void;
  46756. }
  46757. }
  46758. declare module BABYLON.Debug {
  46759. /**
  46760. * Class used to render a debug view of a given skeleton
  46761. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46762. */
  46763. export class SkeletonViewer {
  46764. /** defines the skeleton to render */
  46765. skeleton: Skeleton;
  46766. /** defines the mesh attached to the skeleton */
  46767. mesh: AbstractMesh;
  46768. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46769. autoUpdateBonesMatrices: boolean;
  46770. /** defines the rendering group id to use with the viewer */
  46771. renderingGroupId: number;
  46772. /** Gets or sets the color used to render the skeleton */
  46773. color: Color3;
  46774. private _scene;
  46775. private _debugLines;
  46776. private _debugMesh;
  46777. private _isEnabled;
  46778. private _renderFunction;
  46779. private _utilityLayer;
  46780. /**
  46781. * Returns the mesh used to render the bones
  46782. */
  46783. get debugMesh(): Nullable<LinesMesh>;
  46784. /**
  46785. * Creates a new SkeletonViewer
  46786. * @param skeleton defines the skeleton to render
  46787. * @param mesh defines the mesh attached to the skeleton
  46788. * @param scene defines the hosting scene
  46789. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46790. * @param renderingGroupId defines the rendering group id to use with the viewer
  46791. */
  46792. constructor(
  46793. /** defines the skeleton to render */
  46794. skeleton: Skeleton,
  46795. /** defines the mesh attached to the skeleton */
  46796. mesh: AbstractMesh, scene: Scene,
  46797. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46798. autoUpdateBonesMatrices?: boolean,
  46799. /** defines the rendering group id to use with the viewer */
  46800. renderingGroupId?: number);
  46801. /** Gets or sets a boolean indicating if the viewer is enabled */
  46802. set isEnabled(value: boolean);
  46803. get isEnabled(): boolean;
  46804. private _getBonePosition;
  46805. private _getLinesForBonesWithLength;
  46806. private _getLinesForBonesNoLength;
  46807. /** Update the viewer to sync with current skeleton state */
  46808. update(): void;
  46809. /** Release associated resources */
  46810. dispose(): void;
  46811. }
  46812. }
  46813. declare module BABYLON {
  46814. /**
  46815. * Options to create the null engine
  46816. */
  46817. export class NullEngineOptions {
  46818. /**
  46819. * Render width (Default: 512)
  46820. */
  46821. renderWidth: number;
  46822. /**
  46823. * Render height (Default: 256)
  46824. */
  46825. renderHeight: number;
  46826. /**
  46827. * Texture size (Default: 512)
  46828. */
  46829. textureSize: number;
  46830. /**
  46831. * If delta time between frames should be constant
  46832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46833. */
  46834. deterministicLockstep: boolean;
  46835. /**
  46836. * Maximum about of steps between frames (Default: 4)
  46837. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46838. */
  46839. lockstepMaxSteps: number;
  46840. }
  46841. /**
  46842. * The null engine class provides support for headless version of babylon.js.
  46843. * This can be used in server side scenario or for testing purposes
  46844. */
  46845. export class NullEngine extends Engine {
  46846. private _options;
  46847. /**
  46848. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46850. * @returns true if engine is in deterministic lock step mode
  46851. */
  46852. isDeterministicLockStep(): boolean;
  46853. /**
  46854. * Gets the max steps when engine is running in deterministic lock step
  46855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46856. * @returns the max steps
  46857. */
  46858. getLockstepMaxSteps(): number;
  46859. /**
  46860. * Gets the current hardware scaling level.
  46861. * By default the hardware scaling level is computed from the window device ratio.
  46862. * 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.
  46863. * @returns a number indicating the current hardware scaling level
  46864. */
  46865. getHardwareScalingLevel(): number;
  46866. constructor(options?: NullEngineOptions);
  46867. /**
  46868. * Creates a vertex buffer
  46869. * @param vertices the data for the vertex buffer
  46870. * @returns the new WebGL static buffer
  46871. */
  46872. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46873. /**
  46874. * Creates a new index buffer
  46875. * @param indices defines the content of the index buffer
  46876. * @param updatable defines if the index buffer must be updatable
  46877. * @returns a new webGL buffer
  46878. */
  46879. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46880. /**
  46881. * Clear the current render buffer or the current render target (if any is set up)
  46882. * @param color defines the color to use
  46883. * @param backBuffer defines if the back buffer must be cleared
  46884. * @param depth defines if the depth buffer must be cleared
  46885. * @param stencil defines if the stencil buffer must be cleared
  46886. */
  46887. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46888. /**
  46889. * Gets the current render width
  46890. * @param useScreen defines if screen size must be used (or the current render target if any)
  46891. * @returns a number defining the current render width
  46892. */
  46893. getRenderWidth(useScreen?: boolean): number;
  46894. /**
  46895. * Gets the current render height
  46896. * @param useScreen defines if screen size must be used (or the current render target if any)
  46897. * @returns a number defining the current render height
  46898. */
  46899. getRenderHeight(useScreen?: boolean): number;
  46900. /**
  46901. * Set the WebGL's viewport
  46902. * @param viewport defines the viewport element to be used
  46903. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46904. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46905. */
  46906. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46907. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46908. /**
  46909. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46910. * @param pipelineContext defines the pipeline context to use
  46911. * @param uniformsNames defines the list of uniform names
  46912. * @returns an array of webGL uniform locations
  46913. */
  46914. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46915. /**
  46916. * Gets the lsit of active attributes for a given webGL program
  46917. * @param pipelineContext defines the pipeline context to use
  46918. * @param attributesNames defines the list of attribute names to get
  46919. * @returns an array of indices indicating the offset of each attribute
  46920. */
  46921. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46922. /**
  46923. * Binds an effect to the webGL context
  46924. * @param effect defines the effect to bind
  46925. */
  46926. bindSamplers(effect: Effect): void;
  46927. /**
  46928. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46929. * @param effect defines the effect to activate
  46930. */
  46931. enableEffect(effect: Effect): void;
  46932. /**
  46933. * Set various states to the webGL context
  46934. * @param culling defines backface culling state
  46935. * @param zOffset defines the value to apply to zOffset (0 by default)
  46936. * @param force defines if states must be applied even if cache is up to date
  46937. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46938. */
  46939. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46940. /**
  46941. * Set the value of an uniform to an array of int32
  46942. * @param uniform defines the webGL uniform location where to store the value
  46943. * @param array defines the array of int32 to store
  46944. */
  46945. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46946. /**
  46947. * Set the value of an uniform to an array of int32 (stored as vec2)
  46948. * @param uniform defines the webGL uniform location where to store the value
  46949. * @param array defines the array of int32 to store
  46950. */
  46951. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46952. /**
  46953. * Set the value of an uniform to an array of int32 (stored as vec3)
  46954. * @param uniform defines the webGL uniform location where to store the value
  46955. * @param array defines the array of int32 to store
  46956. */
  46957. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46958. /**
  46959. * Set the value of an uniform to an array of int32 (stored as vec4)
  46960. * @param uniform defines the webGL uniform location where to store the value
  46961. * @param array defines the array of int32 to store
  46962. */
  46963. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46964. /**
  46965. * Set the value of an uniform to an array of float32
  46966. * @param uniform defines the webGL uniform location where to store the value
  46967. * @param array defines the array of float32 to store
  46968. */
  46969. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46970. /**
  46971. * Set the value of an uniform to an array of float32 (stored as vec2)
  46972. * @param uniform defines the webGL uniform location where to store the value
  46973. * @param array defines the array of float32 to store
  46974. */
  46975. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46976. /**
  46977. * Set the value of an uniform to an array of float32 (stored as vec3)
  46978. * @param uniform defines the webGL uniform location where to store the value
  46979. * @param array defines the array of float32 to store
  46980. */
  46981. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46982. /**
  46983. * Set the value of an uniform to an array of float32 (stored as vec4)
  46984. * @param uniform defines the webGL uniform location where to store the value
  46985. * @param array defines the array of float32 to store
  46986. */
  46987. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46988. /**
  46989. * Set the value of an uniform to an array of number
  46990. * @param uniform defines the webGL uniform location where to store the value
  46991. * @param array defines the array of number to store
  46992. */
  46993. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46994. /**
  46995. * Set the value of an uniform to an array of number (stored as vec2)
  46996. * @param uniform defines the webGL uniform location where to store the value
  46997. * @param array defines the array of number to store
  46998. */
  46999. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47000. /**
  47001. * Set the value of an uniform to an array of number (stored as vec3)
  47002. * @param uniform defines the webGL uniform location where to store the value
  47003. * @param array defines the array of number to store
  47004. */
  47005. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47006. /**
  47007. * Set the value of an uniform to an array of number (stored as vec4)
  47008. * @param uniform defines the webGL uniform location where to store the value
  47009. * @param array defines the array of number to store
  47010. */
  47011. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47012. /**
  47013. * Set the value of an uniform to an array of float32 (stored as matrices)
  47014. * @param uniform defines the webGL uniform location where to store the value
  47015. * @param matrices defines the array of float32 to store
  47016. */
  47017. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47018. /**
  47019. * Set the value of an uniform to a matrix (3x3)
  47020. * @param uniform defines the webGL uniform location where to store the value
  47021. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47022. */
  47023. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47024. /**
  47025. * Set the value of an uniform to a matrix (2x2)
  47026. * @param uniform defines the webGL uniform location where to store the value
  47027. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47028. */
  47029. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47030. /**
  47031. * Set the value of an uniform to a number (float)
  47032. * @param uniform defines the webGL uniform location where to store the value
  47033. * @param value defines the float number to store
  47034. */
  47035. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47036. /**
  47037. * Set the value of an uniform to a vec2
  47038. * @param uniform defines the webGL uniform location where to store the value
  47039. * @param x defines the 1st component of the value
  47040. * @param y defines the 2nd component of the value
  47041. */
  47042. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47043. /**
  47044. * Set the value of an uniform to a vec3
  47045. * @param uniform defines the webGL uniform location where to store the value
  47046. * @param x defines the 1st component of the value
  47047. * @param y defines the 2nd component of the value
  47048. * @param z defines the 3rd component of the value
  47049. */
  47050. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47051. /**
  47052. * Set the value of an uniform to a boolean
  47053. * @param uniform defines the webGL uniform location where to store the value
  47054. * @param bool defines the boolean to store
  47055. */
  47056. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47057. /**
  47058. * Set the value of an uniform to a vec4
  47059. * @param uniform defines the webGL uniform location where to store the value
  47060. * @param x defines the 1st component of the value
  47061. * @param y defines the 2nd component of the value
  47062. * @param z defines the 3rd component of the value
  47063. * @param w defines the 4th component of the value
  47064. */
  47065. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47066. /**
  47067. * Sets the current alpha mode
  47068. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47069. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47070. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47071. */
  47072. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47073. /**
  47074. * Bind webGl buffers directly to the webGL context
  47075. * @param vertexBuffers defines the vertex buffer to bind
  47076. * @param indexBuffer defines the index buffer to bind
  47077. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47078. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47079. * @param effect defines the effect associated with the vertex buffer
  47080. */
  47081. bindBuffers(vertexBuffers: {
  47082. [key: string]: VertexBuffer;
  47083. }, indexBuffer: DataBuffer, effect: Effect): void;
  47084. /**
  47085. * Force the entire cache to be cleared
  47086. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47087. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47088. */
  47089. wipeCaches(bruteForce?: boolean): void;
  47090. /**
  47091. * Send a draw order
  47092. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47093. * @param indexStart defines the starting index
  47094. * @param indexCount defines the number of index to draw
  47095. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47096. */
  47097. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47098. /**
  47099. * Draw a list of indexed primitives
  47100. * @param fillMode defines the primitive to use
  47101. * @param indexStart defines the starting index
  47102. * @param indexCount defines the number of index to draw
  47103. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47104. */
  47105. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47106. /**
  47107. * Draw a list of unindexed primitives
  47108. * @param fillMode defines the primitive to use
  47109. * @param verticesStart defines the index of first vertex to draw
  47110. * @param verticesCount defines the count of vertices to draw
  47111. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47112. */
  47113. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47114. /** @hidden */
  47115. _createTexture(): WebGLTexture;
  47116. /** @hidden */
  47117. _releaseTexture(texture: InternalTexture): void;
  47118. /**
  47119. * Usually called from Texture.ts.
  47120. * Passed information to create a WebGLTexture
  47121. * @param urlArg defines a value which contains one of the following:
  47122. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47123. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47124. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47125. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47126. * @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)
  47127. * @param scene needed for loading to the correct scene
  47128. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47129. * @param onLoad optional callback to be called upon successful completion
  47130. * @param onError optional callback to be called upon failure
  47131. * @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
  47132. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47133. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47134. * @param forcedExtension defines the extension to use to pick the right loader
  47135. * @param mimeType defines an optional mime type
  47136. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47137. */
  47138. 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;
  47139. /**
  47140. * Creates a new render target texture
  47141. * @param size defines the size of the texture
  47142. * @param options defines the options used to create the texture
  47143. * @returns a new render target texture stored in an InternalTexture
  47144. */
  47145. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47146. /**
  47147. * Update the sampling mode of a given texture
  47148. * @param samplingMode defines the required sampling mode
  47149. * @param texture defines the texture to update
  47150. */
  47151. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47152. /**
  47153. * Binds the frame buffer to the specified texture.
  47154. * @param texture The texture to render to or null for the default canvas
  47155. * @param faceIndex The face of the texture to render to in case of cube texture
  47156. * @param requiredWidth The width of the target to render to
  47157. * @param requiredHeight The height of the target to render to
  47158. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47159. * @param lodLevel defines le lod level to bind to the frame buffer
  47160. */
  47161. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47162. /**
  47163. * Unbind the current render target texture from the webGL context
  47164. * @param texture defines the render target texture to unbind
  47165. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47166. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47167. */
  47168. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47169. /**
  47170. * Creates a dynamic vertex buffer
  47171. * @param vertices the data for the dynamic vertex buffer
  47172. * @returns the new WebGL dynamic buffer
  47173. */
  47174. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47175. /**
  47176. * Update the content of a dynamic texture
  47177. * @param texture defines the texture to update
  47178. * @param canvas defines the canvas containing the source
  47179. * @param invertY defines if data must be stored with Y axis inverted
  47180. * @param premulAlpha defines if alpha is stored as premultiplied
  47181. * @param format defines the format of the data
  47182. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47183. */
  47184. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47185. /**
  47186. * Gets a boolean indicating if all created effects are ready
  47187. * @returns true if all effects are ready
  47188. */
  47189. areAllEffectsReady(): boolean;
  47190. /**
  47191. * @hidden
  47192. * Get the current error code of the webGL context
  47193. * @returns the error code
  47194. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47195. */
  47196. getError(): number;
  47197. /** @hidden */
  47198. _getUnpackAlignement(): number;
  47199. /** @hidden */
  47200. _unpackFlipY(value: boolean): void;
  47201. /**
  47202. * Update a dynamic index buffer
  47203. * @param indexBuffer defines the target index buffer
  47204. * @param indices defines the data to update
  47205. * @param offset defines the offset in the target index buffer where update should start
  47206. */
  47207. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47208. /**
  47209. * Updates a dynamic vertex buffer.
  47210. * @param vertexBuffer the vertex buffer to update
  47211. * @param vertices the data used to update the vertex buffer
  47212. * @param byteOffset the byte offset of the data (optional)
  47213. * @param byteLength the byte length of the data (optional)
  47214. */
  47215. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47216. /** @hidden */
  47217. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47218. /** @hidden */
  47219. _bindTexture(channel: number, texture: InternalTexture): void;
  47220. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47221. /**
  47222. * 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
  47223. */
  47224. releaseEffects(): void;
  47225. displayLoadingUI(): void;
  47226. hideLoadingUI(): void;
  47227. /** @hidden */
  47228. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47229. /** @hidden */
  47230. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47231. /** @hidden */
  47232. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47233. /** @hidden */
  47234. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47235. }
  47236. }
  47237. declare module BABYLON {
  47238. /**
  47239. * @hidden
  47240. **/
  47241. export class _TimeToken {
  47242. _startTimeQuery: Nullable<WebGLQuery>;
  47243. _endTimeQuery: Nullable<WebGLQuery>;
  47244. _timeElapsedQuery: Nullable<WebGLQuery>;
  47245. _timeElapsedQueryEnded: boolean;
  47246. }
  47247. }
  47248. declare module BABYLON {
  47249. /** @hidden */
  47250. export class _OcclusionDataStorage {
  47251. /** @hidden */
  47252. occlusionInternalRetryCounter: number;
  47253. /** @hidden */
  47254. isOcclusionQueryInProgress: boolean;
  47255. /** @hidden */
  47256. isOccluded: boolean;
  47257. /** @hidden */
  47258. occlusionRetryCount: number;
  47259. /** @hidden */
  47260. occlusionType: number;
  47261. /** @hidden */
  47262. occlusionQueryAlgorithmType: number;
  47263. }
  47264. interface Engine {
  47265. /**
  47266. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47267. * @return the new query
  47268. */
  47269. createQuery(): WebGLQuery;
  47270. /**
  47271. * Delete and release a webGL query
  47272. * @param query defines the query to delete
  47273. * @return the current engine
  47274. */
  47275. deleteQuery(query: WebGLQuery): Engine;
  47276. /**
  47277. * Check if a given query has resolved and got its value
  47278. * @param query defines the query to check
  47279. * @returns true if the query got its value
  47280. */
  47281. isQueryResultAvailable(query: WebGLQuery): boolean;
  47282. /**
  47283. * Gets the value of a given query
  47284. * @param query defines the query to check
  47285. * @returns the value of the query
  47286. */
  47287. getQueryResult(query: WebGLQuery): number;
  47288. /**
  47289. * Initiates an occlusion query
  47290. * @param algorithmType defines the algorithm to use
  47291. * @param query defines the query to use
  47292. * @returns the current engine
  47293. * @see http://doc.babylonjs.com/features/occlusionquery
  47294. */
  47295. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47296. /**
  47297. * Ends an occlusion query
  47298. * @see http://doc.babylonjs.com/features/occlusionquery
  47299. * @param algorithmType defines the algorithm to use
  47300. * @returns the current engine
  47301. */
  47302. endOcclusionQuery(algorithmType: number): Engine;
  47303. /**
  47304. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47305. * Please note that only one query can be issued at a time
  47306. * @returns a time token used to track the time span
  47307. */
  47308. startTimeQuery(): Nullable<_TimeToken>;
  47309. /**
  47310. * Ends a time query
  47311. * @param token defines the token used to measure the time span
  47312. * @returns the time spent (in ns)
  47313. */
  47314. endTimeQuery(token: _TimeToken): int;
  47315. /** @hidden */
  47316. _currentNonTimestampToken: Nullable<_TimeToken>;
  47317. /** @hidden */
  47318. _createTimeQuery(): WebGLQuery;
  47319. /** @hidden */
  47320. _deleteTimeQuery(query: WebGLQuery): void;
  47321. /** @hidden */
  47322. _getGlAlgorithmType(algorithmType: number): number;
  47323. /** @hidden */
  47324. _getTimeQueryResult(query: WebGLQuery): any;
  47325. /** @hidden */
  47326. _getTimeQueryAvailability(query: WebGLQuery): any;
  47327. }
  47328. interface AbstractMesh {
  47329. /**
  47330. * Backing filed
  47331. * @hidden
  47332. */
  47333. __occlusionDataStorage: _OcclusionDataStorage;
  47334. /**
  47335. * Access property
  47336. * @hidden
  47337. */
  47338. _occlusionDataStorage: _OcclusionDataStorage;
  47339. /**
  47340. * 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.
  47341. * The default value is -1 which means don't break the query and wait till the result
  47342. * @see http://doc.babylonjs.com/features/occlusionquery
  47343. */
  47344. occlusionRetryCount: number;
  47345. /**
  47346. * 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:
  47347. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47348. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47349. * * 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.
  47350. * @see http://doc.babylonjs.com/features/occlusionquery
  47351. */
  47352. occlusionType: number;
  47353. /**
  47354. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47355. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47356. * * 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.
  47357. * @see http://doc.babylonjs.com/features/occlusionquery
  47358. */
  47359. occlusionQueryAlgorithmType: number;
  47360. /**
  47361. * 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
  47362. * @see http://doc.babylonjs.com/features/occlusionquery
  47363. */
  47364. isOccluded: boolean;
  47365. /**
  47366. * Flag to check the progress status of the query
  47367. * @see http://doc.babylonjs.com/features/occlusionquery
  47368. */
  47369. isOcclusionQueryInProgress: boolean;
  47370. }
  47371. }
  47372. declare module BABYLON {
  47373. /** @hidden */
  47374. export var _forceTransformFeedbackToBundle: boolean;
  47375. interface Engine {
  47376. /**
  47377. * Creates a webGL transform feedback object
  47378. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47379. * @returns the webGL transform feedback object
  47380. */
  47381. createTransformFeedback(): WebGLTransformFeedback;
  47382. /**
  47383. * Delete a webGL transform feedback object
  47384. * @param value defines the webGL transform feedback object to delete
  47385. */
  47386. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47387. /**
  47388. * Bind a webGL transform feedback object to the webgl context
  47389. * @param value defines the webGL transform feedback object to bind
  47390. */
  47391. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47392. /**
  47393. * Begins a transform feedback operation
  47394. * @param usePoints defines if points or triangles must be used
  47395. */
  47396. beginTransformFeedback(usePoints: boolean): void;
  47397. /**
  47398. * Ends a transform feedback operation
  47399. */
  47400. endTransformFeedback(): void;
  47401. /**
  47402. * Specify the varyings to use with transform feedback
  47403. * @param program defines the associated webGL program
  47404. * @param value defines the list of strings representing the varying names
  47405. */
  47406. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47407. /**
  47408. * Bind a webGL buffer for a transform feedback operation
  47409. * @param value defines the webGL buffer to bind
  47410. */
  47411. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47412. }
  47413. }
  47414. declare module BABYLON {
  47415. /**
  47416. * Creation options of the multi render target texture.
  47417. */
  47418. export interface IMultiRenderTargetOptions {
  47419. /**
  47420. * Define if the texture needs to create mip maps after render.
  47421. */
  47422. generateMipMaps?: boolean;
  47423. /**
  47424. * Define the types of all the draw buffers we want to create
  47425. */
  47426. types?: number[];
  47427. /**
  47428. * Define the sampling modes of all the draw buffers we want to create
  47429. */
  47430. samplingModes?: number[];
  47431. /**
  47432. * Define if a depth buffer is required
  47433. */
  47434. generateDepthBuffer?: boolean;
  47435. /**
  47436. * Define if a stencil buffer is required
  47437. */
  47438. generateStencilBuffer?: boolean;
  47439. /**
  47440. * Define if a depth texture is required instead of a depth buffer
  47441. */
  47442. generateDepthTexture?: boolean;
  47443. /**
  47444. * Define the number of desired draw buffers
  47445. */
  47446. textureCount?: number;
  47447. /**
  47448. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47449. */
  47450. doNotChangeAspectRatio?: boolean;
  47451. /**
  47452. * Define the default type of the buffers we are creating
  47453. */
  47454. defaultType?: number;
  47455. }
  47456. /**
  47457. * A multi render target, like a render target provides the ability to render to a texture.
  47458. * Unlike the render target, it can render to several draw buffers in one draw.
  47459. * This is specially interesting in deferred rendering or for any effects requiring more than
  47460. * just one color from a single pass.
  47461. */
  47462. export class MultiRenderTarget extends RenderTargetTexture {
  47463. private _internalTextures;
  47464. private _textures;
  47465. private _multiRenderTargetOptions;
  47466. /**
  47467. * Get if draw buffers are currently supported by the used hardware and browser.
  47468. */
  47469. get isSupported(): boolean;
  47470. /**
  47471. * Get the list of textures generated by the multi render target.
  47472. */
  47473. get textures(): Texture[];
  47474. /**
  47475. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47476. */
  47477. get depthTexture(): Texture;
  47478. /**
  47479. * Set the wrapping mode on U of all the textures we are rendering to.
  47480. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47481. */
  47482. set wrapU(wrap: number);
  47483. /**
  47484. * Set the wrapping mode on V of all the textures we are rendering to.
  47485. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47486. */
  47487. set wrapV(wrap: number);
  47488. /**
  47489. * Instantiate a new multi render target texture.
  47490. * A multi render target, like a render target provides the ability to render to a texture.
  47491. * Unlike the render target, it can render to several draw buffers in one draw.
  47492. * This is specially interesting in deferred rendering or for any effects requiring more than
  47493. * just one color from a single pass.
  47494. * @param name Define the name of the texture
  47495. * @param size Define the size of the buffers to render to
  47496. * @param count Define the number of target we are rendering into
  47497. * @param scene Define the scene the texture belongs to
  47498. * @param options Define the options used to create the multi render target
  47499. */
  47500. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47501. /** @hidden */
  47502. _rebuild(): void;
  47503. private _createInternalTextures;
  47504. private _createTextures;
  47505. /**
  47506. * Define the number of samples used if MSAA is enabled.
  47507. */
  47508. get samples(): number;
  47509. set samples(value: number);
  47510. /**
  47511. * Resize all the textures in the multi render target.
  47512. * Be carrefull as it will recreate all the data in the new texture.
  47513. * @param size Define the new size
  47514. */
  47515. resize(size: any): void;
  47516. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47517. /**
  47518. * Dispose the render targets and their associated resources
  47519. */
  47520. dispose(): void;
  47521. /**
  47522. * Release all the underlying texture used as draw buffers.
  47523. */
  47524. releaseInternalTextures(): void;
  47525. }
  47526. }
  47527. declare module BABYLON {
  47528. interface ThinEngine {
  47529. /**
  47530. * Unbind a list of render target textures from the webGL context
  47531. * This is used only when drawBuffer extension or webGL2 are active
  47532. * @param textures defines the render target textures to unbind
  47533. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47534. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47535. */
  47536. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47537. /**
  47538. * Create a multi render target texture
  47539. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47540. * @param size defines the size of the texture
  47541. * @param options defines the creation options
  47542. * @returns the cube texture as an InternalTexture
  47543. */
  47544. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47545. /**
  47546. * Update the sample count for a given multiple render target texture
  47547. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47548. * @param textures defines the textures to update
  47549. * @param samples defines the sample count to set
  47550. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47551. */
  47552. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47553. }
  47554. }
  47555. declare module BABYLON {
  47556. /**
  47557. * Class used to define an additional view for the engine
  47558. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47559. */
  47560. export class EngineView {
  47561. /** Defines the canvas where to render the view */
  47562. target: HTMLCanvasElement;
  47563. /** Defines an optional camera used to render the view (will use active camera else) */
  47564. camera?: Camera;
  47565. }
  47566. interface Engine {
  47567. /**
  47568. * Gets or sets the HTML element to use for attaching events
  47569. */
  47570. inputElement: Nullable<HTMLElement>;
  47571. /**
  47572. * Gets the current engine view
  47573. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47574. */
  47575. activeView: Nullable<EngineView>;
  47576. /** Gets or sets the list of views */
  47577. views: EngineView[];
  47578. /**
  47579. * Register a new child canvas
  47580. * @param canvas defines the canvas to register
  47581. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47582. * @returns the associated view
  47583. */
  47584. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47585. /**
  47586. * Remove a registered child canvas
  47587. * @param canvas defines the canvas to remove
  47588. * @returns the current engine
  47589. */
  47590. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47591. }
  47592. }
  47593. declare module BABYLON {
  47594. interface Engine {
  47595. /** @hidden */
  47596. _excludedCompressedTextures: string[];
  47597. /** @hidden */
  47598. _textureFormatInUse: string;
  47599. /**
  47600. * Gets the list of texture formats supported
  47601. */
  47602. readonly texturesSupported: Array<string>;
  47603. /**
  47604. * Gets the texture format in use
  47605. */
  47606. readonly textureFormatInUse: Nullable<string>;
  47607. /**
  47608. * Set the compressed texture extensions or file names to skip.
  47609. *
  47610. * @param skippedFiles defines the list of those texture files you want to skip
  47611. * Example: [".dds", ".env", "myfile.png"]
  47612. */
  47613. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47614. /**
  47615. * Set the compressed texture format to use, based on the formats you have, and the formats
  47616. * supported by the hardware / browser.
  47617. *
  47618. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47619. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47620. * to API arguments needed to compressed textures. This puts the burden on the container
  47621. * generator to house the arcane code for determining these for current & future formats.
  47622. *
  47623. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47624. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47625. *
  47626. * Note: The result of this call is not taken into account when a texture is base64.
  47627. *
  47628. * @param formatsAvailable defines the list of those format families you have created
  47629. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47630. *
  47631. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47632. * @returns The extension selected.
  47633. */
  47634. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47635. }
  47636. }
  47637. declare module BABYLON {
  47638. /**
  47639. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47640. */
  47641. export interface CubeMapInfo {
  47642. /**
  47643. * The pixel array for the front face.
  47644. * This is stored in format, left to right, up to down format.
  47645. */
  47646. front: Nullable<ArrayBufferView>;
  47647. /**
  47648. * The pixel array for the back face.
  47649. * This is stored in format, left to right, up to down format.
  47650. */
  47651. back: Nullable<ArrayBufferView>;
  47652. /**
  47653. * The pixel array for the left face.
  47654. * This is stored in format, left to right, up to down format.
  47655. */
  47656. left: Nullable<ArrayBufferView>;
  47657. /**
  47658. * The pixel array for the right face.
  47659. * This is stored in format, left to right, up to down format.
  47660. */
  47661. right: Nullable<ArrayBufferView>;
  47662. /**
  47663. * The pixel array for the up face.
  47664. * This is stored in format, left to right, up to down format.
  47665. */
  47666. up: Nullable<ArrayBufferView>;
  47667. /**
  47668. * The pixel array for the down face.
  47669. * This is stored in format, left to right, up to down format.
  47670. */
  47671. down: Nullable<ArrayBufferView>;
  47672. /**
  47673. * The size of the cubemap stored.
  47674. *
  47675. * Each faces will be size * size pixels.
  47676. */
  47677. size: number;
  47678. /**
  47679. * The format of the texture.
  47680. *
  47681. * RGBA, RGB.
  47682. */
  47683. format: number;
  47684. /**
  47685. * The type of the texture data.
  47686. *
  47687. * UNSIGNED_INT, FLOAT.
  47688. */
  47689. type: number;
  47690. /**
  47691. * Specifies whether the texture is in gamma space.
  47692. */
  47693. gammaSpace: boolean;
  47694. }
  47695. /**
  47696. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47697. */
  47698. export class PanoramaToCubeMapTools {
  47699. private static FACE_FRONT;
  47700. private static FACE_BACK;
  47701. private static FACE_RIGHT;
  47702. private static FACE_LEFT;
  47703. private static FACE_DOWN;
  47704. private static FACE_UP;
  47705. /**
  47706. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47707. *
  47708. * @param float32Array The source data.
  47709. * @param inputWidth The width of the input panorama.
  47710. * @param inputHeight The height of the input panorama.
  47711. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47712. * @return The cubemap data
  47713. */
  47714. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47715. private static CreateCubemapTexture;
  47716. private static CalcProjectionSpherical;
  47717. }
  47718. }
  47719. declare module BABYLON {
  47720. /**
  47721. * Helper class dealing with the extraction of spherical polynomial dataArray
  47722. * from a cube map.
  47723. */
  47724. export class CubeMapToSphericalPolynomialTools {
  47725. private static FileFaces;
  47726. /**
  47727. * Converts a texture to the according Spherical Polynomial data.
  47728. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47729. *
  47730. * @param texture The texture to extract the information from.
  47731. * @return The Spherical Polynomial data.
  47732. */
  47733. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47734. /**
  47735. * Converts a cubemap to the according Spherical Polynomial data.
  47736. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47737. *
  47738. * @param cubeInfo The Cube map to extract the information from.
  47739. * @return The Spherical Polynomial data.
  47740. */
  47741. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47742. }
  47743. }
  47744. declare module BABYLON {
  47745. interface BaseTexture {
  47746. /**
  47747. * Get the polynomial representation of the texture data.
  47748. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47749. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47750. */
  47751. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47752. }
  47753. }
  47754. declare module BABYLON {
  47755. /** @hidden */
  47756. export var rgbdEncodePixelShader: {
  47757. name: string;
  47758. shader: string;
  47759. };
  47760. }
  47761. declare module BABYLON {
  47762. /** @hidden */
  47763. export var rgbdDecodePixelShader: {
  47764. name: string;
  47765. shader: string;
  47766. };
  47767. }
  47768. declare module BABYLON {
  47769. /**
  47770. * Raw texture data and descriptor sufficient for WebGL texture upload
  47771. */
  47772. export interface EnvironmentTextureInfo {
  47773. /**
  47774. * Version of the environment map
  47775. */
  47776. version: number;
  47777. /**
  47778. * Width of image
  47779. */
  47780. width: number;
  47781. /**
  47782. * Irradiance information stored in the file.
  47783. */
  47784. irradiance: any;
  47785. /**
  47786. * Specular information stored in the file.
  47787. */
  47788. specular: any;
  47789. }
  47790. /**
  47791. * Defines One Image in the file. It requires only the position in the file
  47792. * as well as the length.
  47793. */
  47794. interface BufferImageData {
  47795. /**
  47796. * Length of the image data.
  47797. */
  47798. length: number;
  47799. /**
  47800. * Position of the data from the null terminator delimiting the end of the JSON.
  47801. */
  47802. position: number;
  47803. }
  47804. /**
  47805. * Defines the specular data enclosed in the file.
  47806. * This corresponds to the version 1 of the data.
  47807. */
  47808. export interface EnvironmentTextureSpecularInfoV1 {
  47809. /**
  47810. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47811. */
  47812. specularDataPosition?: number;
  47813. /**
  47814. * This contains all the images data needed to reconstruct the cubemap.
  47815. */
  47816. mipmaps: Array<BufferImageData>;
  47817. /**
  47818. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47819. */
  47820. lodGenerationScale: number;
  47821. }
  47822. /**
  47823. * Sets of helpers addressing the serialization and deserialization of environment texture
  47824. * stored in a BabylonJS env file.
  47825. * Those files are usually stored as .env files.
  47826. */
  47827. export class EnvironmentTextureTools {
  47828. /**
  47829. * Magic number identifying the env file.
  47830. */
  47831. private static _MagicBytes;
  47832. /**
  47833. * Gets the environment info from an env file.
  47834. * @param data The array buffer containing the .env bytes.
  47835. * @returns the environment file info (the json header) if successfully parsed.
  47836. */
  47837. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47838. /**
  47839. * Creates an environment texture from a loaded cube texture.
  47840. * @param texture defines the cube texture to convert in env file
  47841. * @return a promise containing the environment data if succesfull.
  47842. */
  47843. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47844. /**
  47845. * Creates a JSON representation of the spherical data.
  47846. * @param texture defines the texture containing the polynomials
  47847. * @return the JSON representation of the spherical info
  47848. */
  47849. private static _CreateEnvTextureIrradiance;
  47850. /**
  47851. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47852. * @param data the image data
  47853. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47854. * @return the views described by info providing access to the underlying buffer
  47855. */
  47856. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47857. /**
  47858. * Uploads the texture info contained in the env file to the GPU.
  47859. * @param texture defines the internal texture to upload to
  47860. * @param data defines the data to load
  47861. * @param info defines the texture info retrieved through the GetEnvInfo method
  47862. * @returns a promise
  47863. */
  47864. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47865. private static _OnImageReadyAsync;
  47866. /**
  47867. * Uploads the levels of image data to the GPU.
  47868. * @param texture defines the internal texture to upload to
  47869. * @param imageData defines the array buffer views of image data [mipmap][face]
  47870. * @returns a promise
  47871. */
  47872. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47873. /**
  47874. * Uploads spherical polynomials information to the texture.
  47875. * @param texture defines the texture we are trying to upload the information to
  47876. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47877. */
  47878. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47879. /** @hidden */
  47880. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47881. }
  47882. }
  47883. declare module BABYLON {
  47884. /**
  47885. * Contains position and normal vectors for a vertex
  47886. */
  47887. export class PositionNormalVertex {
  47888. /** the position of the vertex (defaut: 0,0,0) */
  47889. position: Vector3;
  47890. /** the normal of the vertex (defaut: 0,1,0) */
  47891. normal: Vector3;
  47892. /**
  47893. * Creates a PositionNormalVertex
  47894. * @param position the position of the vertex (defaut: 0,0,0)
  47895. * @param normal the normal of the vertex (defaut: 0,1,0)
  47896. */
  47897. constructor(
  47898. /** the position of the vertex (defaut: 0,0,0) */
  47899. position?: Vector3,
  47900. /** the normal of the vertex (defaut: 0,1,0) */
  47901. normal?: Vector3);
  47902. /**
  47903. * Clones the PositionNormalVertex
  47904. * @returns the cloned PositionNormalVertex
  47905. */
  47906. clone(): PositionNormalVertex;
  47907. }
  47908. /**
  47909. * Contains position, normal and uv vectors for a vertex
  47910. */
  47911. export class PositionNormalTextureVertex {
  47912. /** the position of the vertex (defaut: 0,0,0) */
  47913. position: Vector3;
  47914. /** the normal of the vertex (defaut: 0,1,0) */
  47915. normal: Vector3;
  47916. /** the uv of the vertex (default: 0,0) */
  47917. uv: Vector2;
  47918. /**
  47919. * Creates a PositionNormalTextureVertex
  47920. * @param position the position of the vertex (defaut: 0,0,0)
  47921. * @param normal the normal of the vertex (defaut: 0,1,0)
  47922. * @param uv the uv of the vertex (default: 0,0)
  47923. */
  47924. constructor(
  47925. /** the position of the vertex (defaut: 0,0,0) */
  47926. position?: Vector3,
  47927. /** the normal of the vertex (defaut: 0,1,0) */
  47928. normal?: Vector3,
  47929. /** the uv of the vertex (default: 0,0) */
  47930. uv?: Vector2);
  47931. /**
  47932. * Clones the PositionNormalTextureVertex
  47933. * @returns the cloned PositionNormalTextureVertex
  47934. */
  47935. clone(): PositionNormalTextureVertex;
  47936. }
  47937. }
  47938. declare module BABYLON {
  47939. /** @hidden */
  47940. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47941. private _genericAttributeLocation;
  47942. private _varyingLocationCount;
  47943. private _varyingLocationMap;
  47944. private _replacements;
  47945. private _textureCount;
  47946. private _uniforms;
  47947. lineProcessor(line: string): string;
  47948. attributeProcessor(attribute: string): string;
  47949. varyingProcessor(varying: string, isFragment: boolean): string;
  47950. uniformProcessor(uniform: string): string;
  47951. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47952. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47953. }
  47954. }
  47955. declare module BABYLON {
  47956. /**
  47957. * Container for accessors for natively-stored mesh data buffers.
  47958. */
  47959. class NativeDataBuffer extends DataBuffer {
  47960. /**
  47961. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47962. */
  47963. nativeIndexBuffer?: any;
  47964. /**
  47965. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47966. */
  47967. nativeVertexBuffer?: any;
  47968. }
  47969. /** @hidden */
  47970. class NativeTexture extends InternalTexture {
  47971. getInternalTexture(): InternalTexture;
  47972. getViewCount(): number;
  47973. }
  47974. /** @hidden */
  47975. export class NativeEngine extends Engine {
  47976. private readonly _native;
  47977. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47978. private readonly INVALID_HANDLE;
  47979. getHardwareScalingLevel(): number;
  47980. constructor();
  47981. /**
  47982. * Can be used to override the current requestAnimationFrame requester.
  47983. * @hidden
  47984. */
  47985. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47986. /**
  47987. * Override default engine behavior.
  47988. * @param color
  47989. * @param backBuffer
  47990. * @param depth
  47991. * @param stencil
  47992. */
  47993. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47994. /**
  47995. * Gets host document
  47996. * @returns the host document object
  47997. */
  47998. getHostDocument(): Nullable<Document>;
  47999. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48000. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48001. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48002. recordVertexArrayObject(vertexBuffers: {
  48003. [key: string]: VertexBuffer;
  48004. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48005. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48006. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48007. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48008. /**
  48009. * Draw a list of indexed primitives
  48010. * @param fillMode defines the primitive to use
  48011. * @param indexStart defines the starting index
  48012. * @param indexCount defines the number of index to draw
  48013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48014. */
  48015. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48016. /**
  48017. * Draw a list of unindexed primitives
  48018. * @param fillMode defines the primitive to use
  48019. * @param verticesStart defines the index of first vertex to draw
  48020. * @param verticesCount defines the count of vertices to draw
  48021. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48022. */
  48023. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48024. createPipelineContext(): IPipelineContext;
  48025. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48026. /** @hidden */
  48027. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48028. /** @hidden */
  48029. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48030. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48031. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48032. protected _setProgram(program: WebGLProgram): void;
  48033. _releaseEffect(effect: Effect): void;
  48034. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48035. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48036. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48037. bindSamplers(effect: Effect): void;
  48038. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48039. getRenderWidth(useScreen?: boolean): number;
  48040. getRenderHeight(useScreen?: boolean): number;
  48041. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48042. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48043. /**
  48044. * Set the z offset to apply to current rendering
  48045. * @param value defines the offset to apply
  48046. */
  48047. setZOffset(value: number): void;
  48048. /**
  48049. * Gets the current value of the zOffset
  48050. * @returns the current zOffset state
  48051. */
  48052. getZOffset(): number;
  48053. /**
  48054. * Enable or disable depth buffering
  48055. * @param enable defines the state to set
  48056. */
  48057. setDepthBuffer(enable: boolean): void;
  48058. /**
  48059. * Gets a boolean indicating if depth writing is enabled
  48060. * @returns the current depth writing state
  48061. */
  48062. getDepthWrite(): boolean;
  48063. /**
  48064. * Enable or disable depth writing
  48065. * @param enable defines the state to set
  48066. */
  48067. setDepthWrite(enable: boolean): void;
  48068. /**
  48069. * Enable or disable color writing
  48070. * @param enable defines the state to set
  48071. */
  48072. setColorWrite(enable: boolean): void;
  48073. /**
  48074. * Gets a boolean indicating if color writing is enabled
  48075. * @returns the current color writing state
  48076. */
  48077. getColorWrite(): boolean;
  48078. /**
  48079. * Sets alpha constants used by some alpha blending modes
  48080. * @param r defines the red component
  48081. * @param g defines the green component
  48082. * @param b defines the blue component
  48083. * @param a defines the alpha component
  48084. */
  48085. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48086. /**
  48087. * Sets the current alpha mode
  48088. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48089. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48090. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48091. */
  48092. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48093. /**
  48094. * Gets the current alpha mode
  48095. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48096. * @returns the current alpha mode
  48097. */
  48098. getAlphaMode(): number;
  48099. setInt(uniform: WebGLUniformLocation, int: number): void;
  48100. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48101. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48102. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48103. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48104. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48105. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48106. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48107. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48108. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48109. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48110. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48111. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48112. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48113. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48114. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48115. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48116. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48117. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48118. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48119. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48120. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48121. wipeCaches(bruteForce?: boolean): void;
  48122. _createTexture(): WebGLTexture;
  48123. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48124. /**
  48125. * Usually called from Texture.ts.
  48126. * Passed information to create a WebGLTexture
  48127. * @param urlArg defines a value which contains one of the following:
  48128. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48129. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48130. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48131. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48132. * @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)
  48133. * @param scene needed for loading to the correct scene
  48134. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48135. * @param onLoad optional callback to be called upon successful completion
  48136. * @param onError optional callback to be called upon failure
  48137. * @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
  48138. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48139. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48140. * @param forcedExtension defines the extension to use to pick the right loader
  48141. * @param mimeType defines an optional mime type
  48142. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48143. */
  48144. 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;
  48145. /**
  48146. * Creates a cube texture
  48147. * @param rootUrl defines the url where the files to load is located
  48148. * @param scene defines the current scene
  48149. * @param files defines the list of files to load (1 per face)
  48150. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48151. * @param onLoad defines an optional callback raised when the texture is loaded
  48152. * @param onError defines an optional callback raised if there is an issue to load the texture
  48153. * @param format defines the format of the data
  48154. * @param forcedExtension defines the extension to use to pick the right loader
  48155. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48156. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48157. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48158. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48159. * @returns the cube texture as an InternalTexture
  48160. */
  48161. 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;
  48162. private _getSamplingFilter;
  48163. private static _GetNativeTextureFormat;
  48164. createRenderTargetTexture(size: number | {
  48165. width: number;
  48166. height: number;
  48167. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48168. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48169. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48170. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48171. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48172. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48173. /**
  48174. * Updates a dynamic vertex buffer.
  48175. * @param vertexBuffer the vertex buffer to update
  48176. * @param data the data used to update the vertex buffer
  48177. * @param byteOffset the byte offset of the data (optional)
  48178. * @param byteLength the byte length of the data (optional)
  48179. */
  48180. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48181. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48182. private _updateAnisotropicLevel;
  48183. private _getAddressMode;
  48184. /** @hidden */
  48185. _bindTexture(channel: number, texture: InternalTexture): void;
  48186. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48187. releaseEffects(): void;
  48188. /** @hidden */
  48189. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48190. /** @hidden */
  48191. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48192. /** @hidden */
  48193. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48194. /** @hidden */
  48195. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48196. }
  48197. }
  48198. declare module BABYLON {
  48199. /**
  48200. * Gather the list of clipboard event types as constants.
  48201. */
  48202. export class ClipboardEventTypes {
  48203. /**
  48204. * The clipboard event is fired when a copy command is active (pressed).
  48205. */
  48206. static readonly COPY: number;
  48207. /**
  48208. * The clipboard event is fired when a cut command is active (pressed).
  48209. */
  48210. static readonly CUT: number;
  48211. /**
  48212. * The clipboard event is fired when a paste command is active (pressed).
  48213. */
  48214. static readonly PASTE: number;
  48215. }
  48216. /**
  48217. * This class is used to store clipboard related info for the onClipboardObservable event.
  48218. */
  48219. export class ClipboardInfo {
  48220. /**
  48221. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48222. */
  48223. type: number;
  48224. /**
  48225. * Defines the related dom event
  48226. */
  48227. event: ClipboardEvent;
  48228. /**
  48229. *Creates an instance of ClipboardInfo.
  48230. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48231. * @param event Defines the related dom event
  48232. */
  48233. constructor(
  48234. /**
  48235. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48236. */
  48237. type: number,
  48238. /**
  48239. * Defines the related dom event
  48240. */
  48241. event: ClipboardEvent);
  48242. /**
  48243. * Get the clipboard event's type from the keycode.
  48244. * @param keyCode Defines the keyCode for the current keyboard event.
  48245. * @return {number}
  48246. */
  48247. static GetTypeFromCharacter(keyCode: number): number;
  48248. }
  48249. }
  48250. declare module BABYLON {
  48251. /**
  48252. * Google Daydream controller
  48253. */
  48254. export class DaydreamController extends WebVRController {
  48255. /**
  48256. * Base Url for the controller model.
  48257. */
  48258. static MODEL_BASE_URL: string;
  48259. /**
  48260. * File name for the controller model.
  48261. */
  48262. static MODEL_FILENAME: string;
  48263. /**
  48264. * Gamepad Id prefix used to identify Daydream Controller.
  48265. */
  48266. static readonly GAMEPAD_ID_PREFIX: string;
  48267. /**
  48268. * Creates a new DaydreamController from a gamepad
  48269. * @param vrGamepad the gamepad that the controller should be created from
  48270. */
  48271. constructor(vrGamepad: any);
  48272. /**
  48273. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48274. * @param scene scene in which to add meshes
  48275. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48276. */
  48277. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48278. /**
  48279. * Called once for each button that changed state since the last frame
  48280. * @param buttonIdx Which button index changed
  48281. * @param state New state of the button
  48282. * @param changes Which properties on the state changed since last frame
  48283. */
  48284. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48285. }
  48286. }
  48287. declare module BABYLON {
  48288. /**
  48289. * Gear VR Controller
  48290. */
  48291. export class GearVRController extends WebVRController {
  48292. /**
  48293. * Base Url for the controller model.
  48294. */
  48295. static MODEL_BASE_URL: string;
  48296. /**
  48297. * File name for the controller model.
  48298. */
  48299. static MODEL_FILENAME: string;
  48300. /**
  48301. * Gamepad Id prefix used to identify this controller.
  48302. */
  48303. static readonly GAMEPAD_ID_PREFIX: string;
  48304. private readonly _buttonIndexToObservableNameMap;
  48305. /**
  48306. * Creates a new GearVRController from a gamepad
  48307. * @param vrGamepad the gamepad that the controller should be created from
  48308. */
  48309. constructor(vrGamepad: any);
  48310. /**
  48311. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48312. * @param scene scene in which to add meshes
  48313. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48314. */
  48315. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48316. /**
  48317. * Called once for each button that changed state since the last frame
  48318. * @param buttonIdx Which button index changed
  48319. * @param state New state of the button
  48320. * @param changes Which properties on the state changed since last frame
  48321. */
  48322. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48323. }
  48324. }
  48325. declare module BABYLON {
  48326. /**
  48327. * Generic Controller
  48328. */
  48329. export class GenericController extends WebVRController {
  48330. /**
  48331. * Base Url for the controller model.
  48332. */
  48333. static readonly MODEL_BASE_URL: string;
  48334. /**
  48335. * File name for the controller model.
  48336. */
  48337. static readonly MODEL_FILENAME: string;
  48338. /**
  48339. * Creates a new GenericController from a gamepad
  48340. * @param vrGamepad the gamepad that the controller should be created from
  48341. */
  48342. constructor(vrGamepad: any);
  48343. /**
  48344. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48345. * @param scene scene in which to add meshes
  48346. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48347. */
  48348. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48349. /**
  48350. * Called once for each button that changed state since the last frame
  48351. * @param buttonIdx Which button index changed
  48352. * @param state New state of the button
  48353. * @param changes Which properties on the state changed since last frame
  48354. */
  48355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48356. }
  48357. }
  48358. declare module BABYLON {
  48359. /**
  48360. * Oculus Touch Controller
  48361. */
  48362. export class OculusTouchController extends WebVRController {
  48363. /**
  48364. * Base Url for the controller model.
  48365. */
  48366. static MODEL_BASE_URL: string;
  48367. /**
  48368. * File name for the left controller model.
  48369. */
  48370. static MODEL_LEFT_FILENAME: string;
  48371. /**
  48372. * File name for the right controller model.
  48373. */
  48374. static MODEL_RIGHT_FILENAME: string;
  48375. /**
  48376. * Base Url for the Quest controller model.
  48377. */
  48378. static QUEST_MODEL_BASE_URL: string;
  48379. /**
  48380. * @hidden
  48381. * If the controllers are running on a device that needs the updated Quest controller models
  48382. */
  48383. static _IsQuest: boolean;
  48384. /**
  48385. * Fired when the secondary trigger on this controller is modified
  48386. */
  48387. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48388. /**
  48389. * Fired when the thumb rest on this controller is modified
  48390. */
  48391. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48392. /**
  48393. * Creates a new OculusTouchController from a gamepad
  48394. * @param vrGamepad the gamepad that the controller should be created from
  48395. */
  48396. constructor(vrGamepad: any);
  48397. /**
  48398. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48399. * @param scene scene in which to add meshes
  48400. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48401. */
  48402. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48403. /**
  48404. * Fired when the A button on this controller is modified
  48405. */
  48406. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48407. /**
  48408. * Fired when the B button on this controller is modified
  48409. */
  48410. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48411. /**
  48412. * Fired when the X button on this controller is modified
  48413. */
  48414. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48415. /**
  48416. * Fired when the Y button on this controller is modified
  48417. */
  48418. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48419. /**
  48420. * Called once for each button that changed state since the last frame
  48421. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48422. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48423. * 2) secondary trigger (same)
  48424. * 3) A (right) X (left), touch, pressed = value
  48425. * 4) B / Y
  48426. * 5) thumb rest
  48427. * @param buttonIdx Which button index changed
  48428. * @param state New state of the button
  48429. * @param changes Which properties on the state changed since last frame
  48430. */
  48431. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48432. }
  48433. }
  48434. declare module BABYLON {
  48435. /**
  48436. * Vive Controller
  48437. */
  48438. export class ViveController extends WebVRController {
  48439. /**
  48440. * Base Url for the controller model.
  48441. */
  48442. static MODEL_BASE_URL: string;
  48443. /**
  48444. * File name for the controller model.
  48445. */
  48446. static MODEL_FILENAME: string;
  48447. /**
  48448. * Creates a new ViveController from a gamepad
  48449. * @param vrGamepad the gamepad that the controller should be created from
  48450. */
  48451. constructor(vrGamepad: any);
  48452. /**
  48453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48454. * @param scene scene in which to add meshes
  48455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48456. */
  48457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48458. /**
  48459. * Fired when the left button on this controller is modified
  48460. */
  48461. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48462. /**
  48463. * Fired when the right button on this controller is modified
  48464. */
  48465. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48466. /**
  48467. * Fired when the menu button on this controller is modified
  48468. */
  48469. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48470. /**
  48471. * Called once for each button that changed state since the last frame
  48472. * Vive mapping:
  48473. * 0: touchpad
  48474. * 1: trigger
  48475. * 2: left AND right buttons
  48476. * 3: menu button
  48477. * @param buttonIdx Which button index changed
  48478. * @param state New state of the button
  48479. * @param changes Which properties on the state changed since last frame
  48480. */
  48481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48482. }
  48483. }
  48484. declare module BABYLON {
  48485. /**
  48486. * Defines the WindowsMotionController object that the state of the windows motion controller
  48487. */
  48488. export class WindowsMotionController extends WebVRController {
  48489. /**
  48490. * The base url used to load the left and right controller models
  48491. */
  48492. static MODEL_BASE_URL: string;
  48493. /**
  48494. * The name of the left controller model file
  48495. */
  48496. static MODEL_LEFT_FILENAME: string;
  48497. /**
  48498. * The name of the right controller model file
  48499. */
  48500. static MODEL_RIGHT_FILENAME: string;
  48501. /**
  48502. * The controller name prefix for this controller type
  48503. */
  48504. static readonly GAMEPAD_ID_PREFIX: string;
  48505. /**
  48506. * The controller id pattern for this controller type
  48507. */
  48508. private static readonly GAMEPAD_ID_PATTERN;
  48509. private _loadedMeshInfo;
  48510. protected readonly _mapping: {
  48511. buttons: string[];
  48512. buttonMeshNames: {
  48513. 'trigger': string;
  48514. 'menu': string;
  48515. 'grip': string;
  48516. 'thumbstick': string;
  48517. 'trackpad': string;
  48518. };
  48519. buttonObservableNames: {
  48520. 'trigger': string;
  48521. 'menu': string;
  48522. 'grip': string;
  48523. 'thumbstick': string;
  48524. 'trackpad': string;
  48525. };
  48526. axisMeshNames: string[];
  48527. pointingPoseMeshName: string;
  48528. };
  48529. /**
  48530. * Fired when the trackpad on this controller is clicked
  48531. */
  48532. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48533. /**
  48534. * Fired when the trackpad on this controller is modified
  48535. */
  48536. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48537. /**
  48538. * The current x and y values of this controller's trackpad
  48539. */
  48540. trackpad: StickValues;
  48541. /**
  48542. * Creates a new WindowsMotionController from a gamepad
  48543. * @param vrGamepad the gamepad that the controller should be created from
  48544. */
  48545. constructor(vrGamepad: any);
  48546. /**
  48547. * Fired when the trigger on this controller is modified
  48548. */
  48549. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48550. /**
  48551. * Fired when the menu button on this controller is modified
  48552. */
  48553. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48554. /**
  48555. * Fired when the grip button on this controller is modified
  48556. */
  48557. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48558. /**
  48559. * Fired when the thumbstick button on this controller is modified
  48560. */
  48561. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48562. /**
  48563. * Fired when the touchpad button on this controller is modified
  48564. */
  48565. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48566. /**
  48567. * Fired when the touchpad values on this controller are modified
  48568. */
  48569. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48570. protected _updateTrackpad(): void;
  48571. /**
  48572. * Called once per frame by the engine.
  48573. */
  48574. update(): void;
  48575. /**
  48576. * Called once for each button that changed state since the last frame
  48577. * @param buttonIdx Which button index changed
  48578. * @param state New state of the button
  48579. * @param changes Which properties on the state changed since last frame
  48580. */
  48581. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48582. /**
  48583. * Moves the buttons on the controller mesh based on their current state
  48584. * @param buttonName the name of the button to move
  48585. * @param buttonValue the value of the button which determines the buttons new position
  48586. */
  48587. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48588. /**
  48589. * Moves the axis on the controller mesh based on its current state
  48590. * @param axis the index of the axis
  48591. * @param axisValue the value of the axis which determines the meshes new position
  48592. * @hidden
  48593. */
  48594. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48595. /**
  48596. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48597. * @param scene scene in which to add meshes
  48598. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48599. */
  48600. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48601. /**
  48602. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48603. * can be transformed by button presses and axes values, based on this._mapping.
  48604. *
  48605. * @param scene scene in which the meshes exist
  48606. * @param meshes list of meshes that make up the controller model to process
  48607. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48608. */
  48609. private processModel;
  48610. private createMeshInfo;
  48611. /**
  48612. * Gets the ray of the controller in the direction the controller is pointing
  48613. * @param length the length the resulting ray should be
  48614. * @returns a ray in the direction the controller is pointing
  48615. */
  48616. getForwardRay(length?: number): Ray;
  48617. /**
  48618. * Disposes of the controller
  48619. */
  48620. dispose(): void;
  48621. }
  48622. /**
  48623. * This class represents a new windows motion controller in XR.
  48624. */
  48625. export class XRWindowsMotionController extends WindowsMotionController {
  48626. /**
  48627. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48628. */
  48629. protected readonly _mapping: {
  48630. buttons: string[];
  48631. buttonMeshNames: {
  48632. 'trigger': string;
  48633. 'menu': string;
  48634. 'grip': string;
  48635. 'thumbstick': string;
  48636. 'trackpad': string;
  48637. };
  48638. buttonObservableNames: {
  48639. 'trigger': string;
  48640. 'menu': string;
  48641. 'grip': string;
  48642. 'thumbstick': string;
  48643. 'trackpad': string;
  48644. };
  48645. axisMeshNames: string[];
  48646. pointingPoseMeshName: string;
  48647. };
  48648. /**
  48649. * Construct a new XR-Based windows motion controller
  48650. *
  48651. * @param gamepadInfo the gamepad object from the browser
  48652. */
  48653. constructor(gamepadInfo: any);
  48654. /**
  48655. * holds the thumbstick values (X,Y)
  48656. */
  48657. thumbstickValues: StickValues;
  48658. /**
  48659. * Fired when the thumbstick on this controller is clicked
  48660. */
  48661. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48662. /**
  48663. * Fired when the thumbstick on this controller is modified
  48664. */
  48665. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48666. /**
  48667. * Fired when the touchpad button on this controller is modified
  48668. */
  48669. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48670. /**
  48671. * Fired when the touchpad values on this controller are modified
  48672. */
  48673. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48674. /**
  48675. * Fired when the thumbstick button on this controller is modified
  48676. * here to prevent breaking changes
  48677. */
  48678. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48679. /**
  48680. * updating the thumbstick(!) and not the trackpad.
  48681. * This is named this way due to the difference between WebVR and XR and to avoid
  48682. * changing the parent class.
  48683. */
  48684. protected _updateTrackpad(): void;
  48685. /**
  48686. * Disposes the class with joy
  48687. */
  48688. dispose(): void;
  48689. }
  48690. }
  48691. declare module BABYLON {
  48692. /**
  48693. * Class containing static functions to help procedurally build meshes
  48694. */
  48695. export class PolyhedronBuilder {
  48696. /**
  48697. * Creates a polyhedron mesh
  48698. * * 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
  48699. * * The parameter `size` (positive float, default 1) sets the polygon size
  48700. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48701. * * 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`
  48702. * * 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
  48703. * * 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)`)
  48704. * * 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
  48705. * * 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
  48706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48707. * * 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
  48708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48709. * @param name defines the name of the mesh
  48710. * @param options defines the options used to create the mesh
  48711. * @param scene defines the hosting scene
  48712. * @returns the polyhedron mesh
  48713. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48714. */
  48715. static CreatePolyhedron(name: string, options: {
  48716. type?: number;
  48717. size?: number;
  48718. sizeX?: number;
  48719. sizeY?: number;
  48720. sizeZ?: number;
  48721. custom?: any;
  48722. faceUV?: Vector4[];
  48723. faceColors?: Color4[];
  48724. flat?: boolean;
  48725. updatable?: boolean;
  48726. sideOrientation?: number;
  48727. frontUVs?: Vector4;
  48728. backUVs?: Vector4;
  48729. }, scene?: Nullable<Scene>): Mesh;
  48730. }
  48731. }
  48732. declare module BABYLON {
  48733. /**
  48734. * Gizmo that enables scaling a mesh along 3 axis
  48735. */
  48736. export class ScaleGizmo extends Gizmo {
  48737. /**
  48738. * Internal gizmo used for interactions on the x axis
  48739. */
  48740. xGizmo: AxisScaleGizmo;
  48741. /**
  48742. * Internal gizmo used for interactions on the y axis
  48743. */
  48744. yGizmo: AxisScaleGizmo;
  48745. /**
  48746. * Internal gizmo used for interactions on the z axis
  48747. */
  48748. zGizmo: AxisScaleGizmo;
  48749. /**
  48750. * Internal gizmo used to scale all axis equally
  48751. */
  48752. uniformScaleGizmo: AxisScaleGizmo;
  48753. private _meshAttached;
  48754. private _updateGizmoRotationToMatchAttachedMesh;
  48755. private _snapDistance;
  48756. private _scaleRatio;
  48757. private _uniformScalingMesh;
  48758. private _octahedron;
  48759. private _sensitivity;
  48760. /** Fires an event when any of it's sub gizmos are dragged */
  48761. onDragStartObservable: Observable<unknown>;
  48762. /** Fires an event when any of it's sub gizmos are released from dragging */
  48763. onDragEndObservable: Observable<unknown>;
  48764. get attachedMesh(): Nullable<AbstractMesh>;
  48765. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48766. /**
  48767. * Creates a ScaleGizmo
  48768. * @param gizmoLayer The utility layer the gizmo will be added to
  48769. */
  48770. constructor(gizmoLayer?: UtilityLayerRenderer);
  48771. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48772. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48773. /**
  48774. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48775. */
  48776. set snapDistance(value: number);
  48777. get snapDistance(): number;
  48778. /**
  48779. * Ratio for the scale of the gizmo (Default: 1)
  48780. */
  48781. set scaleRatio(value: number);
  48782. get scaleRatio(): number;
  48783. /**
  48784. * Sensitivity factor for dragging (Default: 1)
  48785. */
  48786. set sensitivity(value: number);
  48787. get sensitivity(): number;
  48788. /**
  48789. * Disposes of the gizmo
  48790. */
  48791. dispose(): void;
  48792. }
  48793. }
  48794. declare module BABYLON {
  48795. /**
  48796. * Single axis scale gizmo
  48797. */
  48798. export class AxisScaleGizmo extends Gizmo {
  48799. /**
  48800. * Drag behavior responsible for the gizmos dragging interactions
  48801. */
  48802. dragBehavior: PointerDragBehavior;
  48803. private _pointerObserver;
  48804. /**
  48805. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48806. */
  48807. snapDistance: number;
  48808. /**
  48809. * Event that fires each time the gizmo snaps to a new location.
  48810. * * snapDistance is the the change in distance
  48811. */
  48812. onSnapObservable: Observable<{
  48813. snapDistance: number;
  48814. }>;
  48815. /**
  48816. * If the scaling operation should be done on all axis (default: false)
  48817. */
  48818. uniformScaling: boolean;
  48819. /**
  48820. * Custom sensitivity value for the drag strength
  48821. */
  48822. sensitivity: number;
  48823. private _isEnabled;
  48824. private _parent;
  48825. private _arrow;
  48826. private _coloredMaterial;
  48827. private _hoverMaterial;
  48828. /**
  48829. * Creates an AxisScaleGizmo
  48830. * @param gizmoLayer The utility layer the gizmo will be added to
  48831. * @param dragAxis The axis which the gizmo will be able to scale on
  48832. * @param color The color of the gizmo
  48833. */
  48834. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48835. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48836. /**
  48837. * If the gizmo is enabled
  48838. */
  48839. set isEnabled(value: boolean);
  48840. get isEnabled(): boolean;
  48841. /**
  48842. * Disposes of the gizmo
  48843. */
  48844. dispose(): void;
  48845. /**
  48846. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48847. * @param mesh The mesh to replace the default mesh of the gizmo
  48848. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48849. */
  48850. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48851. }
  48852. }
  48853. declare module BABYLON {
  48854. /**
  48855. * Bounding box gizmo
  48856. */
  48857. export class BoundingBoxGizmo extends Gizmo {
  48858. private _lineBoundingBox;
  48859. private _rotateSpheresParent;
  48860. private _scaleBoxesParent;
  48861. private _boundingDimensions;
  48862. private _renderObserver;
  48863. private _pointerObserver;
  48864. private _scaleDragSpeed;
  48865. private _tmpQuaternion;
  48866. private _tmpVector;
  48867. private _tmpRotationMatrix;
  48868. /**
  48869. * 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)
  48870. */
  48871. ignoreChildren: boolean;
  48872. /**
  48873. * 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)
  48874. */
  48875. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48876. /**
  48877. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48878. */
  48879. rotationSphereSize: number;
  48880. /**
  48881. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48882. */
  48883. scaleBoxSize: number;
  48884. /**
  48885. * 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)
  48886. */
  48887. fixedDragMeshScreenSize: boolean;
  48888. /**
  48889. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48890. */
  48891. fixedDragMeshScreenSizeDistanceFactor: number;
  48892. /**
  48893. * Fired when a rotation sphere or scale box is dragged
  48894. */
  48895. onDragStartObservable: Observable<{}>;
  48896. /**
  48897. * Fired when a scale box is dragged
  48898. */
  48899. onScaleBoxDragObservable: Observable<{}>;
  48900. /**
  48901. * Fired when a scale box drag is ended
  48902. */
  48903. onScaleBoxDragEndObservable: Observable<{}>;
  48904. /**
  48905. * Fired when a rotation sphere is dragged
  48906. */
  48907. onRotationSphereDragObservable: Observable<{}>;
  48908. /**
  48909. * Fired when a rotation sphere drag is ended
  48910. */
  48911. onRotationSphereDragEndObservable: Observable<{}>;
  48912. /**
  48913. * 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)
  48914. */
  48915. scalePivot: Nullable<Vector3>;
  48916. /**
  48917. * Mesh used as a pivot to rotate the attached mesh
  48918. */
  48919. private _anchorMesh;
  48920. private _existingMeshScale;
  48921. private _dragMesh;
  48922. private pointerDragBehavior;
  48923. private coloredMaterial;
  48924. private hoverColoredMaterial;
  48925. /**
  48926. * Sets the color of the bounding box gizmo
  48927. * @param color the color to set
  48928. */
  48929. setColor(color: Color3): void;
  48930. /**
  48931. * Creates an BoundingBoxGizmo
  48932. * @param gizmoLayer The utility layer the gizmo will be added to
  48933. * @param color The color of the gizmo
  48934. */
  48935. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48936. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48937. private _selectNode;
  48938. /**
  48939. * Updates the bounding box information for the Gizmo
  48940. */
  48941. updateBoundingBox(): void;
  48942. private _updateRotationSpheres;
  48943. private _updateScaleBoxes;
  48944. /**
  48945. * Enables rotation on the specified axis and disables rotation on the others
  48946. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48947. */
  48948. setEnabledRotationAxis(axis: string): void;
  48949. /**
  48950. * Enables/disables scaling
  48951. * @param enable if scaling should be enabled
  48952. * @param homogeneousScaling defines if scaling should only be homogeneous
  48953. */
  48954. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48955. private _updateDummy;
  48956. /**
  48957. * Enables a pointer drag behavior on the bounding box of the gizmo
  48958. */
  48959. enableDragBehavior(): void;
  48960. /**
  48961. * Disposes of the gizmo
  48962. */
  48963. dispose(): void;
  48964. /**
  48965. * 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)
  48966. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48967. * @returns the bounding box mesh with the passed in mesh as a child
  48968. */
  48969. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48970. /**
  48971. * CustomMeshes are not supported by this gizmo
  48972. * @param mesh The mesh to replace the default mesh of the gizmo
  48973. */
  48974. setCustomMesh(mesh: Mesh): void;
  48975. }
  48976. }
  48977. declare module BABYLON {
  48978. /**
  48979. * Single plane rotation gizmo
  48980. */
  48981. export class PlaneRotationGizmo extends Gizmo {
  48982. /**
  48983. * Drag behavior responsible for the gizmos dragging interactions
  48984. */
  48985. dragBehavior: PointerDragBehavior;
  48986. private _pointerObserver;
  48987. /**
  48988. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48989. */
  48990. snapDistance: number;
  48991. /**
  48992. * Event that fires each time the gizmo snaps to a new location.
  48993. * * snapDistance is the the change in distance
  48994. */
  48995. onSnapObservable: Observable<{
  48996. snapDistance: number;
  48997. }>;
  48998. private _isEnabled;
  48999. private _parent;
  49000. /**
  49001. * Creates a PlaneRotationGizmo
  49002. * @param gizmoLayer The utility layer the gizmo will be added to
  49003. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49004. * @param color The color of the gizmo
  49005. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49006. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49007. */
  49008. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49009. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49010. /**
  49011. * If the gizmo is enabled
  49012. */
  49013. set isEnabled(value: boolean);
  49014. get isEnabled(): boolean;
  49015. /**
  49016. * Disposes of the gizmo
  49017. */
  49018. dispose(): void;
  49019. }
  49020. }
  49021. declare module BABYLON {
  49022. /**
  49023. * Gizmo that enables rotating a mesh along 3 axis
  49024. */
  49025. export class RotationGizmo extends Gizmo {
  49026. /**
  49027. * Internal gizmo used for interactions on the x axis
  49028. */
  49029. xGizmo: PlaneRotationGizmo;
  49030. /**
  49031. * Internal gizmo used for interactions on the y axis
  49032. */
  49033. yGizmo: PlaneRotationGizmo;
  49034. /**
  49035. * Internal gizmo used for interactions on the z axis
  49036. */
  49037. zGizmo: PlaneRotationGizmo;
  49038. /** Fires an event when any of it's sub gizmos are dragged */
  49039. onDragStartObservable: Observable<unknown>;
  49040. /** Fires an event when any of it's sub gizmos are released from dragging */
  49041. onDragEndObservable: Observable<unknown>;
  49042. private _meshAttached;
  49043. get attachedMesh(): Nullable<AbstractMesh>;
  49044. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49045. /**
  49046. * Creates a RotationGizmo
  49047. * @param gizmoLayer The utility layer the gizmo will be added to
  49048. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49049. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49050. */
  49051. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49052. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49053. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49054. /**
  49055. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49056. */
  49057. set snapDistance(value: number);
  49058. get snapDistance(): number;
  49059. /**
  49060. * Ratio for the scale of the gizmo (Default: 1)
  49061. */
  49062. set scaleRatio(value: number);
  49063. get scaleRatio(): number;
  49064. /**
  49065. * Disposes of the gizmo
  49066. */
  49067. dispose(): void;
  49068. /**
  49069. * CustomMeshes are not supported by this gizmo
  49070. * @param mesh The mesh to replace the default mesh of the gizmo
  49071. */
  49072. setCustomMesh(mesh: Mesh): void;
  49073. }
  49074. }
  49075. declare module BABYLON {
  49076. /**
  49077. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49078. */
  49079. export class GizmoManager implements IDisposable {
  49080. private scene;
  49081. /**
  49082. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49083. */
  49084. gizmos: {
  49085. positionGizmo: Nullable<PositionGizmo>;
  49086. rotationGizmo: Nullable<RotationGizmo>;
  49087. scaleGizmo: Nullable<ScaleGizmo>;
  49088. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49089. };
  49090. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49091. clearGizmoOnEmptyPointerEvent: boolean;
  49092. /** Fires an event when the manager is attached to a mesh */
  49093. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49094. private _gizmosEnabled;
  49095. private _pointerObserver;
  49096. private _attachedMesh;
  49097. private _boundingBoxColor;
  49098. private _defaultUtilityLayer;
  49099. private _defaultKeepDepthUtilityLayer;
  49100. /**
  49101. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49102. */
  49103. boundingBoxDragBehavior: SixDofDragBehavior;
  49104. /**
  49105. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49106. */
  49107. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49108. /**
  49109. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49110. */
  49111. usePointerToAttachGizmos: boolean;
  49112. /**
  49113. * Utility layer that the bounding box gizmo belongs to
  49114. */
  49115. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49116. /**
  49117. * Utility layer that all gizmos besides bounding box belong to
  49118. */
  49119. get utilityLayer(): UtilityLayerRenderer;
  49120. /**
  49121. * Instatiates a gizmo manager
  49122. * @param scene the scene to overlay the gizmos on top of
  49123. */
  49124. constructor(scene: Scene);
  49125. /**
  49126. * Attaches a set of gizmos to the specified mesh
  49127. * @param mesh The mesh the gizmo's should be attached to
  49128. */
  49129. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49130. /**
  49131. * If the position gizmo is enabled
  49132. */
  49133. set positionGizmoEnabled(value: boolean);
  49134. get positionGizmoEnabled(): boolean;
  49135. /**
  49136. * If the rotation gizmo is enabled
  49137. */
  49138. set rotationGizmoEnabled(value: boolean);
  49139. get rotationGizmoEnabled(): boolean;
  49140. /**
  49141. * If the scale gizmo is enabled
  49142. */
  49143. set scaleGizmoEnabled(value: boolean);
  49144. get scaleGizmoEnabled(): boolean;
  49145. /**
  49146. * If the boundingBox gizmo is enabled
  49147. */
  49148. set boundingBoxGizmoEnabled(value: boolean);
  49149. get boundingBoxGizmoEnabled(): boolean;
  49150. /**
  49151. * Disposes of the gizmo manager
  49152. */
  49153. dispose(): void;
  49154. }
  49155. }
  49156. declare module BABYLON {
  49157. /**
  49158. * A directional light is defined by a direction (what a surprise!).
  49159. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49160. * 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.
  49161. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49162. */
  49163. export class DirectionalLight extends ShadowLight {
  49164. private _shadowFrustumSize;
  49165. /**
  49166. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49167. */
  49168. get shadowFrustumSize(): number;
  49169. /**
  49170. * Specifies a fix frustum size for the shadow generation.
  49171. */
  49172. set shadowFrustumSize(value: number);
  49173. private _shadowOrthoScale;
  49174. /**
  49175. * Gets the shadow projection scale against the optimal computed one.
  49176. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49177. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49178. */
  49179. get shadowOrthoScale(): number;
  49180. /**
  49181. * Sets the shadow projection scale against the optimal computed one.
  49182. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49183. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49184. */
  49185. set shadowOrthoScale(value: number);
  49186. /**
  49187. * Automatically compute the projection matrix to best fit (including all the casters)
  49188. * on each frame.
  49189. */
  49190. autoUpdateExtends: boolean;
  49191. /**
  49192. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49193. * on each frame. autoUpdateExtends must be set to true for this to work
  49194. */
  49195. autoCalcShadowZBounds: boolean;
  49196. private _orthoLeft;
  49197. private _orthoRight;
  49198. private _orthoTop;
  49199. private _orthoBottom;
  49200. /**
  49201. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49202. * The directional light is emitted from everywhere in the given direction.
  49203. * It can cast shadows.
  49204. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49205. * @param name The friendly name of the light
  49206. * @param direction The direction of the light
  49207. * @param scene The scene the light belongs to
  49208. */
  49209. constructor(name: string, direction: Vector3, scene: Scene);
  49210. /**
  49211. * Returns the string "DirectionalLight".
  49212. * @return The class name
  49213. */
  49214. getClassName(): string;
  49215. /**
  49216. * Returns the integer 1.
  49217. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49218. */
  49219. getTypeID(): number;
  49220. /**
  49221. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49222. * Returns the DirectionalLight Shadow projection matrix.
  49223. */
  49224. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49225. /**
  49226. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49227. * Returns the DirectionalLight Shadow projection matrix.
  49228. */
  49229. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49230. /**
  49231. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49232. * Returns the DirectionalLight Shadow projection matrix.
  49233. */
  49234. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49235. protected _buildUniformLayout(): void;
  49236. /**
  49237. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49238. * @param effect The effect to update
  49239. * @param lightIndex The index of the light in the effect to update
  49240. * @returns The directional light
  49241. */
  49242. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49243. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49244. /**
  49245. * Gets the minZ used for shadow according to both the scene and the light.
  49246. *
  49247. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49248. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49249. * @param activeCamera The camera we are returning the min for
  49250. * @returns the depth min z
  49251. */
  49252. getDepthMinZ(activeCamera: Camera): number;
  49253. /**
  49254. * Gets the maxZ used for shadow according to both the scene and the light.
  49255. *
  49256. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49257. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49258. * @param activeCamera The camera we are returning the max for
  49259. * @returns the depth max z
  49260. */
  49261. getDepthMaxZ(activeCamera: Camera): number;
  49262. /**
  49263. * Prepares the list of defines specific to the light type.
  49264. * @param defines the list of defines
  49265. * @param lightIndex defines the index of the light for the effect
  49266. */
  49267. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49268. }
  49269. }
  49270. declare module BABYLON {
  49271. /**
  49272. * Class containing static functions to help procedurally build meshes
  49273. */
  49274. export class HemisphereBuilder {
  49275. /**
  49276. * Creates a hemisphere mesh
  49277. * @param name defines the name of the mesh
  49278. * @param options defines the options used to create the mesh
  49279. * @param scene defines the hosting scene
  49280. * @returns the hemisphere mesh
  49281. */
  49282. static CreateHemisphere(name: string, options: {
  49283. segments?: number;
  49284. diameter?: number;
  49285. sideOrientation?: number;
  49286. }, scene: any): Mesh;
  49287. }
  49288. }
  49289. declare module BABYLON {
  49290. /**
  49291. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49292. * These values define a cone of light starting from the position, emitting toward the direction.
  49293. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49294. * and the exponent defines the speed of the decay of the light with distance (reach).
  49295. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49296. */
  49297. export class SpotLight extends ShadowLight {
  49298. private _angle;
  49299. private _innerAngle;
  49300. private _cosHalfAngle;
  49301. private _lightAngleScale;
  49302. private _lightAngleOffset;
  49303. /**
  49304. * Gets the cone angle of the spot light in Radians.
  49305. */
  49306. get angle(): number;
  49307. /**
  49308. * Sets the cone angle of the spot light in Radians.
  49309. */
  49310. set angle(value: number);
  49311. /**
  49312. * Only used in gltf falloff mode, this defines the angle where
  49313. * the directional falloff will start before cutting at angle which could be seen
  49314. * as outer angle.
  49315. */
  49316. get innerAngle(): number;
  49317. /**
  49318. * Only used in gltf falloff mode, this defines the angle where
  49319. * the directional falloff will start before cutting at angle which could be seen
  49320. * as outer angle.
  49321. */
  49322. set innerAngle(value: number);
  49323. private _shadowAngleScale;
  49324. /**
  49325. * Allows scaling the angle of the light for shadow generation only.
  49326. */
  49327. get shadowAngleScale(): number;
  49328. /**
  49329. * Allows scaling the angle of the light for shadow generation only.
  49330. */
  49331. set shadowAngleScale(value: number);
  49332. /**
  49333. * The light decay speed with the distance from the emission spot.
  49334. */
  49335. exponent: number;
  49336. private _projectionTextureMatrix;
  49337. /**
  49338. * Allows reading the projecton texture
  49339. */
  49340. get projectionTextureMatrix(): Matrix;
  49341. protected _projectionTextureLightNear: number;
  49342. /**
  49343. * Gets the near clip of the Spotlight for texture projection.
  49344. */
  49345. get projectionTextureLightNear(): number;
  49346. /**
  49347. * Sets the near clip of the Spotlight for texture projection.
  49348. */
  49349. set projectionTextureLightNear(value: number);
  49350. protected _projectionTextureLightFar: number;
  49351. /**
  49352. * Gets the far clip of the Spotlight for texture projection.
  49353. */
  49354. get projectionTextureLightFar(): number;
  49355. /**
  49356. * Sets the far clip of the Spotlight for texture projection.
  49357. */
  49358. set projectionTextureLightFar(value: number);
  49359. protected _projectionTextureUpDirection: Vector3;
  49360. /**
  49361. * Gets the Up vector of the Spotlight for texture projection.
  49362. */
  49363. get projectionTextureUpDirection(): Vector3;
  49364. /**
  49365. * Sets the Up vector of the Spotlight for texture projection.
  49366. */
  49367. set projectionTextureUpDirection(value: Vector3);
  49368. private _projectionTexture;
  49369. /**
  49370. * Gets the projection texture of the light.
  49371. */
  49372. get projectionTexture(): Nullable<BaseTexture>;
  49373. /**
  49374. * Sets the projection texture of the light.
  49375. */
  49376. set projectionTexture(value: Nullable<BaseTexture>);
  49377. private _projectionTextureViewLightDirty;
  49378. private _projectionTextureProjectionLightDirty;
  49379. private _projectionTextureDirty;
  49380. private _projectionTextureViewTargetVector;
  49381. private _projectionTextureViewLightMatrix;
  49382. private _projectionTextureProjectionLightMatrix;
  49383. private _projectionTextureScalingMatrix;
  49384. /**
  49385. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49386. * It can cast shadows.
  49387. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49388. * @param name The light friendly name
  49389. * @param position The position of the spot light in the scene
  49390. * @param direction The direction of the light in the scene
  49391. * @param angle The cone angle of the light in Radians
  49392. * @param exponent The light decay speed with the distance from the emission spot
  49393. * @param scene The scene the lights belongs to
  49394. */
  49395. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49396. /**
  49397. * Returns the string "SpotLight".
  49398. * @returns the class name
  49399. */
  49400. getClassName(): string;
  49401. /**
  49402. * Returns the integer 2.
  49403. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49404. */
  49405. getTypeID(): number;
  49406. /**
  49407. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49408. */
  49409. protected _setDirection(value: Vector3): void;
  49410. /**
  49411. * Overrides the position setter to recompute the projection texture view light Matrix.
  49412. */
  49413. protected _setPosition(value: Vector3): void;
  49414. /**
  49415. * 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.
  49416. * Returns the SpotLight.
  49417. */
  49418. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49419. protected _computeProjectionTextureViewLightMatrix(): void;
  49420. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49421. /**
  49422. * Main function for light texture projection matrix computing.
  49423. */
  49424. protected _computeProjectionTextureMatrix(): void;
  49425. protected _buildUniformLayout(): void;
  49426. private _computeAngleValues;
  49427. /**
  49428. * Sets the passed Effect "effect" with the Light textures.
  49429. * @param effect The effect to update
  49430. * @param lightIndex The index of the light in the effect to update
  49431. * @returns The light
  49432. */
  49433. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49434. /**
  49435. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49436. * @param effect The effect to update
  49437. * @param lightIndex The index of the light in the effect to update
  49438. * @returns The spot light
  49439. */
  49440. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49441. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49442. /**
  49443. * Disposes the light and the associated resources.
  49444. */
  49445. dispose(): void;
  49446. /**
  49447. * Prepares the list of defines specific to the light type.
  49448. * @param defines the list of defines
  49449. * @param lightIndex defines the index of the light for the effect
  49450. */
  49451. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49452. }
  49453. }
  49454. declare module BABYLON {
  49455. /**
  49456. * Gizmo that enables viewing a light
  49457. */
  49458. export class LightGizmo extends Gizmo {
  49459. private _lightMesh;
  49460. private _material;
  49461. private _cachedPosition;
  49462. private _cachedForward;
  49463. private _attachedMeshParent;
  49464. /**
  49465. * Creates a LightGizmo
  49466. * @param gizmoLayer The utility layer the gizmo will be added to
  49467. */
  49468. constructor(gizmoLayer?: UtilityLayerRenderer);
  49469. private _light;
  49470. /**
  49471. * The light that the gizmo is attached to
  49472. */
  49473. set light(light: Nullable<Light>);
  49474. get light(): Nullable<Light>;
  49475. /**
  49476. * Gets the material used to render the light gizmo
  49477. */
  49478. get material(): StandardMaterial;
  49479. /**
  49480. * @hidden
  49481. * Updates the gizmo to match the attached mesh's position/rotation
  49482. */
  49483. protected _update(): void;
  49484. private static _Scale;
  49485. /**
  49486. * Creates the lines for a light mesh
  49487. */
  49488. private static _CreateLightLines;
  49489. /**
  49490. * Disposes of the light gizmo
  49491. */
  49492. dispose(): void;
  49493. private static _CreateHemisphericLightMesh;
  49494. private static _CreatePointLightMesh;
  49495. private static _CreateSpotLightMesh;
  49496. private static _CreateDirectionalLightMesh;
  49497. }
  49498. }
  49499. declare module BABYLON {
  49500. /** @hidden */
  49501. export var backgroundFragmentDeclaration: {
  49502. name: string;
  49503. shader: string;
  49504. };
  49505. }
  49506. declare module BABYLON {
  49507. /** @hidden */
  49508. export var backgroundUboDeclaration: {
  49509. name: string;
  49510. shader: string;
  49511. };
  49512. }
  49513. declare module BABYLON {
  49514. /** @hidden */
  49515. export var backgroundPixelShader: {
  49516. name: string;
  49517. shader: string;
  49518. };
  49519. }
  49520. declare module BABYLON {
  49521. /** @hidden */
  49522. export var backgroundVertexDeclaration: {
  49523. name: string;
  49524. shader: string;
  49525. };
  49526. }
  49527. declare module BABYLON {
  49528. /** @hidden */
  49529. export var backgroundVertexShader: {
  49530. name: string;
  49531. shader: string;
  49532. };
  49533. }
  49534. declare module BABYLON {
  49535. /**
  49536. * Background material used to create an efficient environement around your scene.
  49537. */
  49538. export class BackgroundMaterial extends PushMaterial {
  49539. /**
  49540. * Standard reflectance value at parallel view angle.
  49541. */
  49542. static StandardReflectance0: number;
  49543. /**
  49544. * Standard reflectance value at grazing angle.
  49545. */
  49546. static StandardReflectance90: number;
  49547. protected _primaryColor: Color3;
  49548. /**
  49549. * Key light Color (multiply against the environement texture)
  49550. */
  49551. primaryColor: Color3;
  49552. protected __perceptualColor: Nullable<Color3>;
  49553. /**
  49554. * Experimental Internal Use Only.
  49555. *
  49556. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49557. * This acts as a helper to set the primary color to a more "human friendly" value.
  49558. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49559. * output color as close as possible from the chosen value.
  49560. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49561. * part of lighting setup.)
  49562. */
  49563. get _perceptualColor(): Nullable<Color3>;
  49564. set _perceptualColor(value: Nullable<Color3>);
  49565. protected _primaryColorShadowLevel: float;
  49566. /**
  49567. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49568. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49569. */
  49570. get primaryColorShadowLevel(): float;
  49571. set primaryColorShadowLevel(value: float);
  49572. protected _primaryColorHighlightLevel: float;
  49573. /**
  49574. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49575. * The primary color is used at the level chosen to define what the white area would look.
  49576. */
  49577. get primaryColorHighlightLevel(): float;
  49578. set primaryColorHighlightLevel(value: float);
  49579. protected _reflectionTexture: Nullable<BaseTexture>;
  49580. /**
  49581. * Reflection Texture used in the material.
  49582. * Should be author in a specific way for the best result (refer to the documentation).
  49583. */
  49584. reflectionTexture: Nullable<BaseTexture>;
  49585. protected _reflectionBlur: float;
  49586. /**
  49587. * Reflection Texture level of blur.
  49588. *
  49589. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49590. * texture twice.
  49591. */
  49592. reflectionBlur: float;
  49593. protected _diffuseTexture: Nullable<BaseTexture>;
  49594. /**
  49595. * Diffuse Texture used in the material.
  49596. * Should be author in a specific way for the best result (refer to the documentation).
  49597. */
  49598. diffuseTexture: Nullable<BaseTexture>;
  49599. protected _shadowLights: Nullable<IShadowLight[]>;
  49600. /**
  49601. * Specify the list of lights casting shadow on the material.
  49602. * All scene shadow lights will be included if null.
  49603. */
  49604. shadowLights: Nullable<IShadowLight[]>;
  49605. protected _shadowLevel: float;
  49606. /**
  49607. * Helps adjusting the shadow to a softer level if required.
  49608. * 0 means black shadows and 1 means no shadows.
  49609. */
  49610. shadowLevel: float;
  49611. protected _sceneCenter: Vector3;
  49612. /**
  49613. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49614. * It is usually zero but might be interesting to modify according to your setup.
  49615. */
  49616. sceneCenter: Vector3;
  49617. protected _opacityFresnel: boolean;
  49618. /**
  49619. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49620. * This helps ensuring a nice transition when the camera goes under the ground.
  49621. */
  49622. opacityFresnel: boolean;
  49623. protected _reflectionFresnel: boolean;
  49624. /**
  49625. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49626. * This helps adding a mirror texture on the ground.
  49627. */
  49628. reflectionFresnel: boolean;
  49629. protected _reflectionFalloffDistance: number;
  49630. /**
  49631. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49632. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49633. */
  49634. reflectionFalloffDistance: number;
  49635. protected _reflectionAmount: number;
  49636. /**
  49637. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49638. */
  49639. reflectionAmount: number;
  49640. protected _reflectionReflectance0: number;
  49641. /**
  49642. * This specifies the weight of the reflection at grazing angle.
  49643. */
  49644. reflectionReflectance0: number;
  49645. protected _reflectionReflectance90: number;
  49646. /**
  49647. * This specifies the weight of the reflection at a perpendicular point of view.
  49648. */
  49649. reflectionReflectance90: number;
  49650. /**
  49651. * Sets the reflection reflectance fresnel values according to the default standard
  49652. * empirically know to work well :-)
  49653. */
  49654. set reflectionStandardFresnelWeight(value: number);
  49655. protected _useRGBColor: boolean;
  49656. /**
  49657. * Helps to directly use the maps channels instead of their level.
  49658. */
  49659. useRGBColor: boolean;
  49660. protected _enableNoise: boolean;
  49661. /**
  49662. * This helps reducing the banding effect that could occur on the background.
  49663. */
  49664. enableNoise: boolean;
  49665. /**
  49666. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49667. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49668. * Recommended to be keep at 1.0 except for special cases.
  49669. */
  49670. get fovMultiplier(): number;
  49671. set fovMultiplier(value: number);
  49672. private _fovMultiplier;
  49673. /**
  49674. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49675. */
  49676. useEquirectangularFOV: boolean;
  49677. private _maxSimultaneousLights;
  49678. /**
  49679. * Number of Simultaneous lights allowed on the material.
  49680. */
  49681. maxSimultaneousLights: int;
  49682. /**
  49683. * Default configuration related to image processing available in the Background Material.
  49684. */
  49685. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49686. /**
  49687. * Keep track of the image processing observer to allow dispose and replace.
  49688. */
  49689. private _imageProcessingObserver;
  49690. /**
  49691. * Attaches a new image processing configuration to the PBR Material.
  49692. * @param configuration (if null the scene configuration will be use)
  49693. */
  49694. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49695. /**
  49696. * Gets the image processing configuration used either in this material.
  49697. */
  49698. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49699. /**
  49700. * Sets the Default image processing configuration used either in the this material.
  49701. *
  49702. * If sets to null, the scene one is in use.
  49703. */
  49704. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49705. /**
  49706. * Gets wether the color curves effect is enabled.
  49707. */
  49708. get cameraColorCurvesEnabled(): boolean;
  49709. /**
  49710. * Sets wether the color curves effect is enabled.
  49711. */
  49712. set cameraColorCurvesEnabled(value: boolean);
  49713. /**
  49714. * Gets wether the color grading effect is enabled.
  49715. */
  49716. get cameraColorGradingEnabled(): boolean;
  49717. /**
  49718. * Gets wether the color grading effect is enabled.
  49719. */
  49720. set cameraColorGradingEnabled(value: boolean);
  49721. /**
  49722. * Gets wether tonemapping is enabled or not.
  49723. */
  49724. get cameraToneMappingEnabled(): boolean;
  49725. /**
  49726. * Sets wether tonemapping is enabled or not
  49727. */
  49728. set cameraToneMappingEnabled(value: boolean);
  49729. /**
  49730. * The camera exposure used on this material.
  49731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49732. * This corresponds to a photographic exposure.
  49733. */
  49734. get cameraExposure(): float;
  49735. /**
  49736. * The camera exposure used on this material.
  49737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49738. * This corresponds to a photographic exposure.
  49739. */
  49740. set cameraExposure(value: float);
  49741. /**
  49742. * Gets The camera contrast used on this material.
  49743. */
  49744. get cameraContrast(): float;
  49745. /**
  49746. * Sets The camera contrast used on this material.
  49747. */
  49748. set cameraContrast(value: float);
  49749. /**
  49750. * Gets the Color Grading 2D Lookup Texture.
  49751. */
  49752. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49753. /**
  49754. * Sets the Color Grading 2D Lookup Texture.
  49755. */
  49756. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49757. /**
  49758. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49759. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49760. * 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;
  49761. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49762. */
  49763. get cameraColorCurves(): Nullable<ColorCurves>;
  49764. /**
  49765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49767. * 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;
  49768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49769. */
  49770. set cameraColorCurves(value: Nullable<ColorCurves>);
  49771. /**
  49772. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49773. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49774. */
  49775. switchToBGR: boolean;
  49776. private _renderTargets;
  49777. private _reflectionControls;
  49778. private _white;
  49779. private _primaryShadowColor;
  49780. private _primaryHighlightColor;
  49781. /**
  49782. * Instantiates a Background Material in the given scene
  49783. * @param name The friendly name of the material
  49784. * @param scene The scene to add the material to
  49785. */
  49786. constructor(name: string, scene: Scene);
  49787. /**
  49788. * Gets a boolean indicating that current material needs to register RTT
  49789. */
  49790. get hasRenderTargetTextures(): boolean;
  49791. /**
  49792. * The entire material has been created in order to prevent overdraw.
  49793. * @returns false
  49794. */
  49795. needAlphaTesting(): boolean;
  49796. /**
  49797. * The entire material has been created in order to prevent overdraw.
  49798. * @returns true if blending is enable
  49799. */
  49800. needAlphaBlending(): boolean;
  49801. /**
  49802. * Checks wether the material is ready to be rendered for a given mesh.
  49803. * @param mesh The mesh to render
  49804. * @param subMesh The submesh to check against
  49805. * @param useInstances Specify wether or not the material is used with instances
  49806. * @returns true if all the dependencies are ready (Textures, Effects...)
  49807. */
  49808. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49809. /**
  49810. * Compute the primary color according to the chosen perceptual color.
  49811. */
  49812. private _computePrimaryColorFromPerceptualColor;
  49813. /**
  49814. * Compute the highlights and shadow colors according to their chosen levels.
  49815. */
  49816. private _computePrimaryColors;
  49817. /**
  49818. * Build the uniform buffer used in the material.
  49819. */
  49820. buildUniformLayout(): void;
  49821. /**
  49822. * Unbind the material.
  49823. */
  49824. unbind(): void;
  49825. /**
  49826. * Bind only the world matrix to the material.
  49827. * @param world The world matrix to bind.
  49828. */
  49829. bindOnlyWorldMatrix(world: Matrix): void;
  49830. /**
  49831. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49832. * @param world The world matrix to bind.
  49833. * @param subMesh The submesh to bind for.
  49834. */
  49835. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49836. /**
  49837. * Checks to see if a texture is used in the material.
  49838. * @param texture - Base texture to use.
  49839. * @returns - Boolean specifying if a texture is used in the material.
  49840. */
  49841. hasTexture(texture: BaseTexture): boolean;
  49842. /**
  49843. * Dispose the material.
  49844. * @param forceDisposeEffect Force disposal of the associated effect.
  49845. * @param forceDisposeTextures Force disposal of the associated textures.
  49846. */
  49847. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49848. /**
  49849. * Clones the material.
  49850. * @param name The cloned name.
  49851. * @returns The cloned material.
  49852. */
  49853. clone(name: string): BackgroundMaterial;
  49854. /**
  49855. * Serializes the current material to its JSON representation.
  49856. * @returns The JSON representation.
  49857. */
  49858. serialize(): any;
  49859. /**
  49860. * Gets the class name of the material
  49861. * @returns "BackgroundMaterial"
  49862. */
  49863. getClassName(): string;
  49864. /**
  49865. * Parse a JSON input to create back a background material.
  49866. * @param source The JSON data to parse
  49867. * @param scene The scene to create the parsed material in
  49868. * @param rootUrl The root url of the assets the material depends upon
  49869. * @returns the instantiated BackgroundMaterial.
  49870. */
  49871. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49872. }
  49873. }
  49874. declare module BABYLON {
  49875. /**
  49876. * Represents the different options available during the creation of
  49877. * a Environment helper.
  49878. *
  49879. * This can control the default ground, skybox and image processing setup of your scene.
  49880. */
  49881. export interface IEnvironmentHelperOptions {
  49882. /**
  49883. * Specifies whether or not to create a ground.
  49884. * True by default.
  49885. */
  49886. createGround: boolean;
  49887. /**
  49888. * Specifies the ground size.
  49889. * 15 by default.
  49890. */
  49891. groundSize: number;
  49892. /**
  49893. * The texture used on the ground for the main color.
  49894. * Comes from the BabylonJS CDN by default.
  49895. *
  49896. * Remarks: Can be either a texture or a url.
  49897. */
  49898. groundTexture: string | BaseTexture;
  49899. /**
  49900. * The color mixed in the ground texture by default.
  49901. * BabylonJS clearColor by default.
  49902. */
  49903. groundColor: Color3;
  49904. /**
  49905. * Specifies the ground opacity.
  49906. * 1 by default.
  49907. */
  49908. groundOpacity: number;
  49909. /**
  49910. * Enables the ground to receive shadows.
  49911. * True by default.
  49912. */
  49913. enableGroundShadow: boolean;
  49914. /**
  49915. * Helps preventing the shadow to be fully black on the ground.
  49916. * 0.5 by default.
  49917. */
  49918. groundShadowLevel: number;
  49919. /**
  49920. * Creates a mirror texture attach to the ground.
  49921. * false by default.
  49922. */
  49923. enableGroundMirror: boolean;
  49924. /**
  49925. * Specifies the ground mirror size ratio.
  49926. * 0.3 by default as the default kernel is 64.
  49927. */
  49928. groundMirrorSizeRatio: number;
  49929. /**
  49930. * Specifies the ground mirror blur kernel size.
  49931. * 64 by default.
  49932. */
  49933. groundMirrorBlurKernel: number;
  49934. /**
  49935. * Specifies the ground mirror visibility amount.
  49936. * 1 by default
  49937. */
  49938. groundMirrorAmount: number;
  49939. /**
  49940. * Specifies the ground mirror reflectance weight.
  49941. * This uses the standard weight of the background material to setup the fresnel effect
  49942. * of the mirror.
  49943. * 1 by default.
  49944. */
  49945. groundMirrorFresnelWeight: number;
  49946. /**
  49947. * Specifies the ground mirror Falloff distance.
  49948. * This can helps reducing the size of the reflection.
  49949. * 0 by Default.
  49950. */
  49951. groundMirrorFallOffDistance: number;
  49952. /**
  49953. * Specifies the ground mirror texture type.
  49954. * Unsigned Int by Default.
  49955. */
  49956. groundMirrorTextureType: number;
  49957. /**
  49958. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49959. * the shown objects.
  49960. */
  49961. groundYBias: number;
  49962. /**
  49963. * Specifies whether or not to create a skybox.
  49964. * True by default.
  49965. */
  49966. createSkybox: boolean;
  49967. /**
  49968. * Specifies the skybox size.
  49969. * 20 by default.
  49970. */
  49971. skyboxSize: number;
  49972. /**
  49973. * The texture used on the skybox for the main color.
  49974. * Comes from the BabylonJS CDN by default.
  49975. *
  49976. * Remarks: Can be either a texture or a url.
  49977. */
  49978. skyboxTexture: string | BaseTexture;
  49979. /**
  49980. * The color mixed in the skybox texture by default.
  49981. * BabylonJS clearColor by default.
  49982. */
  49983. skyboxColor: Color3;
  49984. /**
  49985. * The background rotation around the Y axis of the scene.
  49986. * This helps aligning the key lights of your scene with the background.
  49987. * 0 by default.
  49988. */
  49989. backgroundYRotation: number;
  49990. /**
  49991. * Compute automatically the size of the elements to best fit with the scene.
  49992. */
  49993. sizeAuto: boolean;
  49994. /**
  49995. * Default position of the rootMesh if autoSize is not true.
  49996. */
  49997. rootPosition: Vector3;
  49998. /**
  49999. * Sets up the image processing in the scene.
  50000. * true by default.
  50001. */
  50002. setupImageProcessing: boolean;
  50003. /**
  50004. * The texture used as your environment texture in the scene.
  50005. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50006. *
  50007. * Remarks: Can be either a texture or a url.
  50008. */
  50009. environmentTexture: string | BaseTexture;
  50010. /**
  50011. * The value of the exposure to apply to the scene.
  50012. * 0.6 by default if setupImageProcessing is true.
  50013. */
  50014. cameraExposure: number;
  50015. /**
  50016. * The value of the contrast to apply to the scene.
  50017. * 1.6 by default if setupImageProcessing is true.
  50018. */
  50019. cameraContrast: number;
  50020. /**
  50021. * Specifies whether or not tonemapping should be enabled in the scene.
  50022. * true by default if setupImageProcessing is true.
  50023. */
  50024. toneMappingEnabled: boolean;
  50025. }
  50026. /**
  50027. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50028. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50029. * It also helps with the default setup of your imageProcessing configuration.
  50030. */
  50031. export class EnvironmentHelper {
  50032. /**
  50033. * Default ground texture URL.
  50034. */
  50035. private static _groundTextureCDNUrl;
  50036. /**
  50037. * Default skybox texture URL.
  50038. */
  50039. private static _skyboxTextureCDNUrl;
  50040. /**
  50041. * Default environment texture URL.
  50042. */
  50043. private static _environmentTextureCDNUrl;
  50044. /**
  50045. * Creates the default options for the helper.
  50046. */
  50047. private static _getDefaultOptions;
  50048. private _rootMesh;
  50049. /**
  50050. * Gets the root mesh created by the helper.
  50051. */
  50052. get rootMesh(): Mesh;
  50053. private _skybox;
  50054. /**
  50055. * Gets the skybox created by the helper.
  50056. */
  50057. get skybox(): Nullable<Mesh>;
  50058. private _skyboxTexture;
  50059. /**
  50060. * Gets the skybox texture created by the helper.
  50061. */
  50062. get skyboxTexture(): Nullable<BaseTexture>;
  50063. private _skyboxMaterial;
  50064. /**
  50065. * Gets the skybox material created by the helper.
  50066. */
  50067. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50068. private _ground;
  50069. /**
  50070. * Gets the ground mesh created by the helper.
  50071. */
  50072. get ground(): Nullable<Mesh>;
  50073. private _groundTexture;
  50074. /**
  50075. * Gets the ground texture created by the helper.
  50076. */
  50077. get groundTexture(): Nullable<BaseTexture>;
  50078. private _groundMirror;
  50079. /**
  50080. * Gets the ground mirror created by the helper.
  50081. */
  50082. get groundMirror(): Nullable<MirrorTexture>;
  50083. /**
  50084. * Gets the ground mirror render list to helps pushing the meshes
  50085. * you wish in the ground reflection.
  50086. */
  50087. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50088. private _groundMaterial;
  50089. /**
  50090. * Gets the ground material created by the helper.
  50091. */
  50092. get groundMaterial(): Nullable<BackgroundMaterial>;
  50093. /**
  50094. * Stores the creation options.
  50095. */
  50096. private readonly _scene;
  50097. private _options;
  50098. /**
  50099. * This observable will be notified with any error during the creation of the environment,
  50100. * mainly texture creation errors.
  50101. */
  50102. onErrorObservable: Observable<{
  50103. message?: string;
  50104. exception?: any;
  50105. }>;
  50106. /**
  50107. * constructor
  50108. * @param options Defines the options we want to customize the helper
  50109. * @param scene The scene to add the material to
  50110. */
  50111. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50112. /**
  50113. * Updates the background according to the new options
  50114. * @param options
  50115. */
  50116. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50117. /**
  50118. * Sets the primary color of all the available elements.
  50119. * @param color the main color to affect to the ground and the background
  50120. */
  50121. setMainColor(color: Color3): void;
  50122. /**
  50123. * Setup the image processing according to the specified options.
  50124. */
  50125. private _setupImageProcessing;
  50126. /**
  50127. * Setup the environment texture according to the specified options.
  50128. */
  50129. private _setupEnvironmentTexture;
  50130. /**
  50131. * Setup the background according to the specified options.
  50132. */
  50133. private _setupBackground;
  50134. /**
  50135. * Get the scene sizes according to the setup.
  50136. */
  50137. private _getSceneSize;
  50138. /**
  50139. * Setup the ground according to the specified options.
  50140. */
  50141. private _setupGround;
  50142. /**
  50143. * Setup the ground material according to the specified options.
  50144. */
  50145. private _setupGroundMaterial;
  50146. /**
  50147. * Setup the ground diffuse texture according to the specified options.
  50148. */
  50149. private _setupGroundDiffuseTexture;
  50150. /**
  50151. * Setup the ground mirror texture according to the specified options.
  50152. */
  50153. private _setupGroundMirrorTexture;
  50154. /**
  50155. * Setup the ground to receive the mirror texture.
  50156. */
  50157. private _setupMirrorInGroundMaterial;
  50158. /**
  50159. * Setup the skybox according to the specified options.
  50160. */
  50161. private _setupSkybox;
  50162. /**
  50163. * Setup the skybox material according to the specified options.
  50164. */
  50165. private _setupSkyboxMaterial;
  50166. /**
  50167. * Setup the skybox reflection texture according to the specified options.
  50168. */
  50169. private _setupSkyboxReflectionTexture;
  50170. private _errorHandler;
  50171. /**
  50172. * Dispose all the elements created by the Helper.
  50173. */
  50174. dispose(): void;
  50175. }
  50176. }
  50177. declare module BABYLON {
  50178. /**
  50179. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50180. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50181. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50182. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50183. */
  50184. export class PhotoDome extends TransformNode {
  50185. /**
  50186. * Define the image as a Monoscopic panoramic 360 image.
  50187. */
  50188. static readonly MODE_MONOSCOPIC: number;
  50189. /**
  50190. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50191. */
  50192. static readonly MODE_TOPBOTTOM: number;
  50193. /**
  50194. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50195. */
  50196. static readonly MODE_SIDEBYSIDE: number;
  50197. private _useDirectMapping;
  50198. /**
  50199. * The texture being displayed on the sphere
  50200. */
  50201. protected _photoTexture: Texture;
  50202. /**
  50203. * Gets or sets the texture being displayed on the sphere
  50204. */
  50205. get photoTexture(): Texture;
  50206. set photoTexture(value: Texture);
  50207. /**
  50208. * Observable raised when an error occured while loading the 360 image
  50209. */
  50210. onLoadErrorObservable: Observable<string>;
  50211. /**
  50212. * The skybox material
  50213. */
  50214. protected _material: BackgroundMaterial;
  50215. /**
  50216. * The surface used for the skybox
  50217. */
  50218. protected _mesh: Mesh;
  50219. /**
  50220. * Gets the mesh used for the skybox.
  50221. */
  50222. get mesh(): Mesh;
  50223. /**
  50224. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50225. * Also see the options.resolution property.
  50226. */
  50227. get fovMultiplier(): number;
  50228. set fovMultiplier(value: number);
  50229. private _imageMode;
  50230. /**
  50231. * Gets or set the current video mode for the video. It can be:
  50232. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50233. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50234. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50235. */
  50236. get imageMode(): number;
  50237. set imageMode(value: number);
  50238. /**
  50239. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50240. * @param name Element's name, child elements will append suffixes for their own names.
  50241. * @param urlsOfPhoto defines the url of the photo to display
  50242. * @param options defines an object containing optional or exposed sub element properties
  50243. * @param onError defines a callback called when an error occured while loading the texture
  50244. */
  50245. constructor(name: string, urlOfPhoto: string, options: {
  50246. resolution?: number;
  50247. size?: number;
  50248. useDirectMapping?: boolean;
  50249. faceForward?: boolean;
  50250. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50251. private _onBeforeCameraRenderObserver;
  50252. private _changeImageMode;
  50253. /**
  50254. * Releases resources associated with this node.
  50255. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50256. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50257. */
  50258. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50259. }
  50260. }
  50261. declare module BABYLON {
  50262. /**
  50263. * Class used to host RGBD texture specific utilities
  50264. */
  50265. export class RGBDTextureTools {
  50266. /**
  50267. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50268. * @param texture the texture to expand.
  50269. */
  50270. static ExpandRGBDTexture(texture: Texture): void;
  50271. }
  50272. }
  50273. declare module BABYLON {
  50274. /**
  50275. * Class used to host texture specific utilities
  50276. */
  50277. export class BRDFTextureTools {
  50278. /**
  50279. * Prevents texture cache collision
  50280. */
  50281. private static _instanceNumber;
  50282. /**
  50283. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50284. * @param scene defines the hosting scene
  50285. * @returns the environment BRDF texture
  50286. */
  50287. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50288. private static _environmentBRDFBase64Texture;
  50289. }
  50290. }
  50291. declare module BABYLON {
  50292. /**
  50293. * @hidden
  50294. */
  50295. export interface IMaterialClearCoatDefines {
  50296. CLEARCOAT: boolean;
  50297. CLEARCOAT_DEFAULTIOR: boolean;
  50298. CLEARCOAT_TEXTURE: boolean;
  50299. CLEARCOAT_TEXTUREDIRECTUV: number;
  50300. CLEARCOAT_BUMP: boolean;
  50301. CLEARCOAT_BUMPDIRECTUV: number;
  50302. CLEARCOAT_TINT: boolean;
  50303. CLEARCOAT_TINT_TEXTURE: boolean;
  50304. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50305. /** @hidden */
  50306. _areTexturesDirty: boolean;
  50307. }
  50308. /**
  50309. * Define the code related to the clear coat parameters of the pbr material.
  50310. */
  50311. export class PBRClearCoatConfiguration {
  50312. /**
  50313. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50314. * The default fits with a polyurethane material.
  50315. */
  50316. private static readonly _DefaultIndexOfRefraction;
  50317. private _isEnabled;
  50318. /**
  50319. * Defines if the clear coat is enabled in the material.
  50320. */
  50321. isEnabled: boolean;
  50322. /**
  50323. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50324. */
  50325. intensity: number;
  50326. /**
  50327. * Defines the clear coat layer roughness.
  50328. */
  50329. roughness: number;
  50330. private _indexOfRefraction;
  50331. /**
  50332. * Defines the index of refraction of the clear coat.
  50333. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50334. * The default fits with a polyurethane material.
  50335. * Changing the default value is more performance intensive.
  50336. */
  50337. indexOfRefraction: number;
  50338. private _texture;
  50339. /**
  50340. * Stores the clear coat values in a texture.
  50341. */
  50342. texture: Nullable<BaseTexture>;
  50343. private _bumpTexture;
  50344. /**
  50345. * Define the clear coat specific bump texture.
  50346. */
  50347. bumpTexture: Nullable<BaseTexture>;
  50348. private _isTintEnabled;
  50349. /**
  50350. * Defines if the clear coat tint is enabled in the material.
  50351. */
  50352. isTintEnabled: boolean;
  50353. /**
  50354. * Defines the clear coat tint of the material.
  50355. * This is only use if tint is enabled
  50356. */
  50357. tintColor: Color3;
  50358. /**
  50359. * Defines the distance at which the tint color should be found in the
  50360. * clear coat media.
  50361. * This is only use if tint is enabled
  50362. */
  50363. tintColorAtDistance: number;
  50364. /**
  50365. * Defines the clear coat layer thickness.
  50366. * This is only use if tint is enabled
  50367. */
  50368. tintThickness: number;
  50369. private _tintTexture;
  50370. /**
  50371. * Stores the clear tint values in a texture.
  50372. * rgb is tint
  50373. * a is a thickness factor
  50374. */
  50375. tintTexture: Nullable<BaseTexture>;
  50376. /** @hidden */
  50377. private _internalMarkAllSubMeshesAsTexturesDirty;
  50378. /** @hidden */
  50379. _markAllSubMeshesAsTexturesDirty(): void;
  50380. /**
  50381. * Instantiate a new istance of clear coat configuration.
  50382. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50383. */
  50384. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50385. /**
  50386. * Gets wehter the submesh is ready to be used or not.
  50387. * @param defines the list of "defines" to update.
  50388. * @param scene defines the scene the material belongs to.
  50389. * @param engine defines the engine the material belongs to.
  50390. * @param disableBumpMap defines wether the material disables bump or not.
  50391. * @returns - boolean indicating that the submesh is ready or not.
  50392. */
  50393. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50394. /**
  50395. * Checks to see if a texture is used in the material.
  50396. * @param defines the list of "defines" to update.
  50397. * @param scene defines the scene to the material belongs to.
  50398. */
  50399. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50400. /**
  50401. * Binds the material data.
  50402. * @param uniformBuffer defines the Uniform buffer to fill in.
  50403. * @param scene defines the scene the material belongs to.
  50404. * @param engine defines the engine the material belongs to.
  50405. * @param disableBumpMap defines wether the material disables bump or not.
  50406. * @param isFrozen defines wether the material is frozen or not.
  50407. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50408. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50409. */
  50410. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50411. /**
  50412. * Checks to see if a texture is used in the material.
  50413. * @param texture - Base texture to use.
  50414. * @returns - Boolean specifying if a texture is used in the material.
  50415. */
  50416. hasTexture(texture: BaseTexture): boolean;
  50417. /**
  50418. * Returns an array of the actively used textures.
  50419. * @param activeTextures Array of BaseTextures
  50420. */
  50421. getActiveTextures(activeTextures: BaseTexture[]): void;
  50422. /**
  50423. * Returns the animatable textures.
  50424. * @param animatables Array of animatable textures.
  50425. */
  50426. getAnimatables(animatables: IAnimatable[]): void;
  50427. /**
  50428. * Disposes the resources of the material.
  50429. * @param forceDisposeTextures - Forces the disposal of all textures.
  50430. */
  50431. dispose(forceDisposeTextures?: boolean): void;
  50432. /**
  50433. * Get the current class name of the texture useful for serialization or dynamic coding.
  50434. * @returns "PBRClearCoatConfiguration"
  50435. */
  50436. getClassName(): string;
  50437. /**
  50438. * Add fallbacks to the effect fallbacks list.
  50439. * @param defines defines the Base texture to use.
  50440. * @param fallbacks defines the current fallback list.
  50441. * @param currentRank defines the current fallback rank.
  50442. * @returns the new fallback rank.
  50443. */
  50444. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50445. /**
  50446. * Add the required uniforms to the current list.
  50447. * @param uniforms defines the current uniform list.
  50448. */
  50449. static AddUniforms(uniforms: string[]): void;
  50450. /**
  50451. * Add the required samplers to the current list.
  50452. * @param samplers defines the current sampler list.
  50453. */
  50454. static AddSamplers(samplers: string[]): void;
  50455. /**
  50456. * Add the required uniforms to the current buffer.
  50457. * @param uniformBuffer defines the current uniform buffer.
  50458. */
  50459. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50460. /**
  50461. * Makes a duplicate of the current configuration into another one.
  50462. * @param clearCoatConfiguration define the config where to copy the info
  50463. */
  50464. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50465. /**
  50466. * Serializes this clear coat configuration.
  50467. * @returns - An object with the serialized config.
  50468. */
  50469. serialize(): any;
  50470. /**
  50471. * Parses a anisotropy Configuration from a serialized object.
  50472. * @param source - Serialized object.
  50473. * @param scene Defines the scene we are parsing for
  50474. * @param rootUrl Defines the rootUrl to load from
  50475. */
  50476. parse(source: any, scene: Scene, rootUrl: string): void;
  50477. }
  50478. }
  50479. declare module BABYLON {
  50480. /**
  50481. * @hidden
  50482. */
  50483. export interface IMaterialAnisotropicDefines {
  50484. ANISOTROPIC: boolean;
  50485. ANISOTROPIC_TEXTURE: boolean;
  50486. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50487. MAINUV1: boolean;
  50488. _areTexturesDirty: boolean;
  50489. _needUVs: boolean;
  50490. }
  50491. /**
  50492. * Define the code related to the anisotropic parameters of the pbr material.
  50493. */
  50494. export class PBRAnisotropicConfiguration {
  50495. private _isEnabled;
  50496. /**
  50497. * Defines if the anisotropy is enabled in the material.
  50498. */
  50499. isEnabled: boolean;
  50500. /**
  50501. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50502. */
  50503. intensity: number;
  50504. /**
  50505. * Defines if the effect is along the tangents, bitangents or in between.
  50506. * By default, the effect is "strectching" the highlights along the tangents.
  50507. */
  50508. direction: Vector2;
  50509. private _texture;
  50510. /**
  50511. * Stores the anisotropy values in a texture.
  50512. * rg is direction (like normal from -1 to 1)
  50513. * b is a intensity
  50514. */
  50515. texture: Nullable<BaseTexture>;
  50516. /** @hidden */
  50517. private _internalMarkAllSubMeshesAsTexturesDirty;
  50518. /** @hidden */
  50519. _markAllSubMeshesAsTexturesDirty(): void;
  50520. /**
  50521. * Instantiate a new istance of anisotropy configuration.
  50522. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50523. */
  50524. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50525. /**
  50526. * Specifies that the submesh is ready to be used.
  50527. * @param defines the list of "defines" to update.
  50528. * @param scene defines the scene the material belongs to.
  50529. * @returns - boolean indicating that the submesh is ready or not.
  50530. */
  50531. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50532. /**
  50533. * Checks to see if a texture is used in the material.
  50534. * @param defines the list of "defines" to update.
  50535. * @param mesh the mesh we are preparing the defines for.
  50536. * @param scene defines the scene the material belongs to.
  50537. */
  50538. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50539. /**
  50540. * Binds the material data.
  50541. * @param uniformBuffer defines the Uniform buffer to fill in.
  50542. * @param scene defines the scene the material belongs to.
  50543. * @param isFrozen defines wether the material is frozen or not.
  50544. */
  50545. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50546. /**
  50547. * Checks to see if a texture is used in the material.
  50548. * @param texture - Base texture to use.
  50549. * @returns - Boolean specifying if a texture is used in the material.
  50550. */
  50551. hasTexture(texture: BaseTexture): boolean;
  50552. /**
  50553. * Returns an array of the actively used textures.
  50554. * @param activeTextures Array of BaseTextures
  50555. */
  50556. getActiveTextures(activeTextures: BaseTexture[]): void;
  50557. /**
  50558. * Returns the animatable textures.
  50559. * @param animatables Array of animatable textures.
  50560. */
  50561. getAnimatables(animatables: IAnimatable[]): void;
  50562. /**
  50563. * Disposes the resources of the material.
  50564. * @param forceDisposeTextures - Forces the disposal of all textures.
  50565. */
  50566. dispose(forceDisposeTextures?: boolean): void;
  50567. /**
  50568. * Get the current class name of the texture useful for serialization or dynamic coding.
  50569. * @returns "PBRAnisotropicConfiguration"
  50570. */
  50571. getClassName(): string;
  50572. /**
  50573. * Add fallbacks to the effect fallbacks list.
  50574. * @param defines defines the Base texture to use.
  50575. * @param fallbacks defines the current fallback list.
  50576. * @param currentRank defines the current fallback rank.
  50577. * @returns the new fallback rank.
  50578. */
  50579. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50580. /**
  50581. * Add the required uniforms to the current list.
  50582. * @param uniforms defines the current uniform list.
  50583. */
  50584. static AddUniforms(uniforms: string[]): void;
  50585. /**
  50586. * Add the required uniforms to the current buffer.
  50587. * @param uniformBuffer defines the current uniform buffer.
  50588. */
  50589. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50590. /**
  50591. * Add the required samplers to the current list.
  50592. * @param samplers defines the current sampler list.
  50593. */
  50594. static AddSamplers(samplers: string[]): void;
  50595. /**
  50596. * Makes a duplicate of the current configuration into another one.
  50597. * @param anisotropicConfiguration define the config where to copy the info
  50598. */
  50599. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50600. /**
  50601. * Serializes this anisotropy configuration.
  50602. * @returns - An object with the serialized config.
  50603. */
  50604. serialize(): any;
  50605. /**
  50606. * Parses a anisotropy Configuration from a serialized object.
  50607. * @param source - Serialized object.
  50608. * @param scene Defines the scene we are parsing for
  50609. * @param rootUrl Defines the rootUrl to load from
  50610. */
  50611. parse(source: any, scene: Scene, rootUrl: string): void;
  50612. }
  50613. }
  50614. declare module BABYLON {
  50615. /**
  50616. * @hidden
  50617. */
  50618. export interface IMaterialBRDFDefines {
  50619. BRDF_V_HEIGHT_CORRELATED: boolean;
  50620. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50621. SPHERICAL_HARMONICS: boolean;
  50622. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50623. /** @hidden */
  50624. _areMiscDirty: boolean;
  50625. }
  50626. /**
  50627. * Define the code related to the BRDF parameters of the pbr material.
  50628. */
  50629. export class PBRBRDFConfiguration {
  50630. /**
  50631. * Default value used for the energy conservation.
  50632. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50633. */
  50634. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50635. /**
  50636. * Default value used for the Smith Visibility Height Correlated mode.
  50637. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50638. */
  50639. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50640. /**
  50641. * Default value used for the IBL diffuse part.
  50642. * This can help switching back to the polynomials mode globally which is a tiny bit
  50643. * less GPU intensive at the drawback of a lower quality.
  50644. */
  50645. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50646. /**
  50647. * Default value used for activating energy conservation for the specular workflow.
  50648. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50649. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50650. */
  50651. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50652. private _useEnergyConservation;
  50653. /**
  50654. * Defines if the material uses energy conservation.
  50655. */
  50656. useEnergyConservation: boolean;
  50657. private _useSmithVisibilityHeightCorrelated;
  50658. /**
  50659. * LEGACY Mode set to false
  50660. * Defines if the material uses height smith correlated visibility term.
  50661. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50662. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50663. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50664. * Not relying on height correlated will also disable energy conservation.
  50665. */
  50666. useSmithVisibilityHeightCorrelated: boolean;
  50667. private _useSphericalHarmonics;
  50668. /**
  50669. * LEGACY Mode set to false
  50670. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50671. * diffuse part of the IBL.
  50672. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50673. * to the ground truth.
  50674. */
  50675. useSphericalHarmonics: boolean;
  50676. private _useSpecularGlossinessInputEnergyConservation;
  50677. /**
  50678. * Defines if the material uses energy conservation, when the specular workflow is active.
  50679. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50680. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50681. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50682. */
  50683. useSpecularGlossinessInputEnergyConservation: boolean;
  50684. /** @hidden */
  50685. private _internalMarkAllSubMeshesAsMiscDirty;
  50686. /** @hidden */
  50687. _markAllSubMeshesAsMiscDirty(): void;
  50688. /**
  50689. * Instantiate a new istance of clear coat configuration.
  50690. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50691. */
  50692. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50693. /**
  50694. * Checks to see if a texture is used in the material.
  50695. * @param defines the list of "defines" to update.
  50696. */
  50697. prepareDefines(defines: IMaterialBRDFDefines): void;
  50698. /**
  50699. * Get the current class name of the texture useful for serialization or dynamic coding.
  50700. * @returns "PBRClearCoatConfiguration"
  50701. */
  50702. getClassName(): string;
  50703. /**
  50704. * Makes a duplicate of the current configuration into another one.
  50705. * @param brdfConfiguration define the config where to copy the info
  50706. */
  50707. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50708. /**
  50709. * Serializes this BRDF configuration.
  50710. * @returns - An object with the serialized config.
  50711. */
  50712. serialize(): any;
  50713. /**
  50714. * Parses a anisotropy Configuration from a serialized object.
  50715. * @param source - Serialized object.
  50716. * @param scene Defines the scene we are parsing for
  50717. * @param rootUrl Defines the rootUrl to load from
  50718. */
  50719. parse(source: any, scene: Scene, rootUrl: string): void;
  50720. }
  50721. }
  50722. declare module BABYLON {
  50723. /**
  50724. * @hidden
  50725. */
  50726. export interface IMaterialSheenDefines {
  50727. SHEEN: boolean;
  50728. SHEEN_TEXTURE: boolean;
  50729. SHEEN_TEXTUREDIRECTUV: number;
  50730. SHEEN_LINKWITHALBEDO: boolean;
  50731. SHEEN_ROUGHNESS: boolean;
  50732. SHEEN_ALBEDOSCALING: boolean;
  50733. /** @hidden */
  50734. _areTexturesDirty: boolean;
  50735. }
  50736. /**
  50737. * Define the code related to the Sheen parameters of the pbr material.
  50738. */
  50739. export class PBRSheenConfiguration {
  50740. private _isEnabled;
  50741. /**
  50742. * Defines if the material uses sheen.
  50743. */
  50744. isEnabled: boolean;
  50745. private _linkSheenWithAlbedo;
  50746. /**
  50747. * Defines if the sheen is linked to the sheen color.
  50748. */
  50749. linkSheenWithAlbedo: boolean;
  50750. /**
  50751. * Defines the sheen intensity.
  50752. */
  50753. intensity: number;
  50754. /**
  50755. * Defines the sheen color.
  50756. */
  50757. color: Color3;
  50758. private _texture;
  50759. /**
  50760. * Stores the sheen tint values in a texture.
  50761. * rgb is tint
  50762. * a is a intensity
  50763. */
  50764. texture: Nullable<BaseTexture>;
  50765. private _roughness;
  50766. /**
  50767. * Defines the sheen roughness.
  50768. * It is not taken into account if linkSheenWithAlbedo is true.
  50769. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50770. */
  50771. roughness: Nullable<number>;
  50772. private _albedoScaling;
  50773. /**
  50774. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50775. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50776. * making it easier to setup and tweak the effect
  50777. */
  50778. albedoScaling: boolean;
  50779. /** @hidden */
  50780. private _internalMarkAllSubMeshesAsTexturesDirty;
  50781. /** @hidden */
  50782. _markAllSubMeshesAsTexturesDirty(): void;
  50783. /**
  50784. * Instantiate a new istance of clear coat configuration.
  50785. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50786. */
  50787. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50788. /**
  50789. * Specifies that the submesh is ready to be used.
  50790. * @param defines the list of "defines" to update.
  50791. * @param scene defines the scene the material belongs to.
  50792. * @returns - boolean indicating that the submesh is ready or not.
  50793. */
  50794. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50795. /**
  50796. * Checks to see if a texture is used in the material.
  50797. * @param defines the list of "defines" to update.
  50798. * @param scene defines the scene the material belongs to.
  50799. */
  50800. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50801. /**
  50802. * Binds the material data.
  50803. * @param uniformBuffer defines the Uniform buffer to fill in.
  50804. * @param scene defines the scene the material belongs to.
  50805. * @param isFrozen defines wether the material is frozen or not.
  50806. */
  50807. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50808. /**
  50809. * Checks to see if a texture is used in the material.
  50810. * @param texture - Base texture to use.
  50811. * @returns - Boolean specifying if a texture is used in the material.
  50812. */
  50813. hasTexture(texture: BaseTexture): boolean;
  50814. /**
  50815. * Returns an array of the actively used textures.
  50816. * @param activeTextures Array of BaseTextures
  50817. */
  50818. getActiveTextures(activeTextures: BaseTexture[]): void;
  50819. /**
  50820. * Returns the animatable textures.
  50821. * @param animatables Array of animatable textures.
  50822. */
  50823. getAnimatables(animatables: IAnimatable[]): void;
  50824. /**
  50825. * Disposes the resources of the material.
  50826. * @param forceDisposeTextures - Forces the disposal of all textures.
  50827. */
  50828. dispose(forceDisposeTextures?: boolean): void;
  50829. /**
  50830. * Get the current class name of the texture useful for serialization or dynamic coding.
  50831. * @returns "PBRSheenConfiguration"
  50832. */
  50833. getClassName(): string;
  50834. /**
  50835. * Add fallbacks to the effect fallbacks list.
  50836. * @param defines defines the Base texture to use.
  50837. * @param fallbacks defines the current fallback list.
  50838. * @param currentRank defines the current fallback rank.
  50839. * @returns the new fallback rank.
  50840. */
  50841. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50842. /**
  50843. * Add the required uniforms to the current list.
  50844. * @param uniforms defines the current uniform list.
  50845. */
  50846. static AddUniforms(uniforms: string[]): void;
  50847. /**
  50848. * Add the required uniforms to the current buffer.
  50849. * @param uniformBuffer defines the current uniform buffer.
  50850. */
  50851. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50852. /**
  50853. * Add the required samplers to the current list.
  50854. * @param samplers defines the current sampler list.
  50855. */
  50856. static AddSamplers(samplers: string[]): void;
  50857. /**
  50858. * Makes a duplicate of the current configuration into another one.
  50859. * @param sheenConfiguration define the config where to copy the info
  50860. */
  50861. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50862. /**
  50863. * Serializes this BRDF configuration.
  50864. * @returns - An object with the serialized config.
  50865. */
  50866. serialize(): any;
  50867. /**
  50868. * Parses a anisotropy Configuration from a serialized object.
  50869. * @param source - Serialized object.
  50870. * @param scene Defines the scene we are parsing for
  50871. * @param rootUrl Defines the rootUrl to load from
  50872. */
  50873. parse(source: any, scene: Scene, rootUrl: string): void;
  50874. }
  50875. }
  50876. declare module BABYLON {
  50877. /**
  50878. * @hidden
  50879. */
  50880. export interface IMaterialSubSurfaceDefines {
  50881. SUBSURFACE: boolean;
  50882. SS_REFRACTION: boolean;
  50883. SS_TRANSLUCENCY: boolean;
  50884. SS_SCATERRING: boolean;
  50885. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50886. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50887. SS_REFRACTIONMAP_3D: boolean;
  50888. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50889. SS_LODINREFRACTIONALPHA: boolean;
  50890. SS_GAMMAREFRACTION: boolean;
  50891. SS_RGBDREFRACTION: boolean;
  50892. SS_LINEARSPECULARREFRACTION: boolean;
  50893. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50894. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50895. /** @hidden */
  50896. _areTexturesDirty: boolean;
  50897. }
  50898. /**
  50899. * Define the code related to the sub surface parameters of the pbr material.
  50900. */
  50901. export class PBRSubSurfaceConfiguration {
  50902. private _isRefractionEnabled;
  50903. /**
  50904. * Defines if the refraction is enabled in the material.
  50905. */
  50906. isRefractionEnabled: boolean;
  50907. private _isTranslucencyEnabled;
  50908. /**
  50909. * Defines if the translucency is enabled in the material.
  50910. */
  50911. isTranslucencyEnabled: boolean;
  50912. private _isScatteringEnabled;
  50913. /**
  50914. * Defines the refraction intensity of the material.
  50915. * The refraction when enabled replaces the Diffuse part of the material.
  50916. * The intensity helps transitionning between diffuse and refraction.
  50917. */
  50918. refractionIntensity: number;
  50919. /**
  50920. * Defines the translucency intensity of the material.
  50921. * When translucency has been enabled, this defines how much of the "translucency"
  50922. * is addded to the diffuse part of the material.
  50923. */
  50924. translucencyIntensity: number;
  50925. /**
  50926. * Defines the scattering intensity of the material.
  50927. * When scattering has been enabled, this defines how much of the "scattered light"
  50928. * is addded to the diffuse part of the material.
  50929. */
  50930. scatteringIntensity: number;
  50931. private _thicknessTexture;
  50932. /**
  50933. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50934. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50935. * 0 would mean minimumThickness
  50936. * 1 would mean maximumThickness
  50937. * The other channels might be use as a mask to vary the different effects intensity.
  50938. */
  50939. thicknessTexture: Nullable<BaseTexture>;
  50940. private _refractionTexture;
  50941. /**
  50942. * Defines the texture to use for refraction.
  50943. */
  50944. refractionTexture: Nullable<BaseTexture>;
  50945. private _indexOfRefraction;
  50946. /**
  50947. * Defines the index of refraction used in the material.
  50948. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50949. */
  50950. indexOfRefraction: number;
  50951. private _invertRefractionY;
  50952. /**
  50953. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50954. */
  50955. invertRefractionY: boolean;
  50956. private _linkRefractionWithTransparency;
  50957. /**
  50958. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50959. * Materials half opaque for instance using refraction could benefit from this control.
  50960. */
  50961. linkRefractionWithTransparency: boolean;
  50962. /**
  50963. * Defines the minimum thickness stored in the thickness map.
  50964. * If no thickness map is defined, this value will be used to simulate thickness.
  50965. */
  50966. minimumThickness: number;
  50967. /**
  50968. * Defines the maximum thickness stored in the thickness map.
  50969. */
  50970. maximumThickness: number;
  50971. /**
  50972. * Defines the volume tint of the material.
  50973. * This is used for both translucency and scattering.
  50974. */
  50975. tintColor: Color3;
  50976. /**
  50977. * Defines the distance at which the tint color should be found in the media.
  50978. * This is used for refraction only.
  50979. */
  50980. tintColorAtDistance: number;
  50981. /**
  50982. * Defines how far each channel transmit through the media.
  50983. * It is defined as a color to simplify it selection.
  50984. */
  50985. diffusionDistance: Color3;
  50986. private _useMaskFromThicknessTexture;
  50987. /**
  50988. * Stores the intensity of the different subsurface effects in the thickness texture.
  50989. * * the green channel is the translucency intensity.
  50990. * * the blue channel is the scattering intensity.
  50991. * * the alpha channel is the refraction intensity.
  50992. */
  50993. useMaskFromThicknessTexture: boolean;
  50994. /** @hidden */
  50995. private _internalMarkAllSubMeshesAsTexturesDirty;
  50996. /** @hidden */
  50997. _markAllSubMeshesAsTexturesDirty(): void;
  50998. /**
  50999. * Instantiate a new istance of sub surface configuration.
  51000. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51001. */
  51002. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51003. /**
  51004. * Gets wehter the submesh is ready to be used or not.
  51005. * @param defines the list of "defines" to update.
  51006. * @param scene defines the scene the material belongs to.
  51007. * @returns - boolean indicating that the submesh is ready or not.
  51008. */
  51009. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51010. /**
  51011. * Checks to see if a texture is used in the material.
  51012. * @param defines the list of "defines" to update.
  51013. * @param scene defines the scene to the material belongs to.
  51014. */
  51015. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51016. /**
  51017. * Binds the material data.
  51018. * @param uniformBuffer defines the Uniform buffer to fill in.
  51019. * @param scene defines the scene the material belongs to.
  51020. * @param engine defines the engine the material belongs to.
  51021. * @param isFrozen defines wether the material is frozen or not.
  51022. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51023. */
  51024. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51025. /**
  51026. * Unbinds the material from the mesh.
  51027. * @param activeEffect defines the effect that should be unbound from.
  51028. * @returns true if unbound, otherwise false
  51029. */
  51030. unbind(activeEffect: Effect): boolean;
  51031. /**
  51032. * Returns the texture used for refraction or null if none is used.
  51033. * @param scene defines the scene the material belongs to.
  51034. * @returns - Refraction texture if present. If no refraction texture and refraction
  51035. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51036. */
  51037. private _getRefractionTexture;
  51038. /**
  51039. * Returns true if alpha blending should be disabled.
  51040. */
  51041. get disableAlphaBlending(): boolean;
  51042. /**
  51043. * Fills the list of render target textures.
  51044. * @param renderTargets the list of render targets to update
  51045. */
  51046. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51047. /**
  51048. * Checks to see if a texture is used in the material.
  51049. * @param texture - Base texture to use.
  51050. * @returns - Boolean specifying if a texture is used in the material.
  51051. */
  51052. hasTexture(texture: BaseTexture): boolean;
  51053. /**
  51054. * Gets a boolean indicating that current material needs to register RTT
  51055. * @returns true if this uses a render target otherwise false.
  51056. */
  51057. hasRenderTargetTextures(): boolean;
  51058. /**
  51059. * Returns an array of the actively used textures.
  51060. * @param activeTextures Array of BaseTextures
  51061. */
  51062. getActiveTextures(activeTextures: BaseTexture[]): void;
  51063. /**
  51064. * Returns the animatable textures.
  51065. * @param animatables Array of animatable textures.
  51066. */
  51067. getAnimatables(animatables: IAnimatable[]): void;
  51068. /**
  51069. * Disposes the resources of the material.
  51070. * @param forceDisposeTextures - Forces the disposal of all textures.
  51071. */
  51072. dispose(forceDisposeTextures?: boolean): void;
  51073. /**
  51074. * Get the current class name of the texture useful for serialization or dynamic coding.
  51075. * @returns "PBRSubSurfaceConfiguration"
  51076. */
  51077. getClassName(): string;
  51078. /**
  51079. * Add fallbacks to the effect fallbacks list.
  51080. * @param defines defines the Base texture to use.
  51081. * @param fallbacks defines the current fallback list.
  51082. * @param currentRank defines the current fallback rank.
  51083. * @returns the new fallback rank.
  51084. */
  51085. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51086. /**
  51087. * Add the required uniforms to the current list.
  51088. * @param uniforms defines the current uniform list.
  51089. */
  51090. static AddUniforms(uniforms: string[]): void;
  51091. /**
  51092. * Add the required samplers to the current list.
  51093. * @param samplers defines the current sampler list.
  51094. */
  51095. static AddSamplers(samplers: string[]): void;
  51096. /**
  51097. * Add the required uniforms to the current buffer.
  51098. * @param uniformBuffer defines the current uniform buffer.
  51099. */
  51100. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51101. /**
  51102. * Makes a duplicate of the current configuration into another one.
  51103. * @param configuration define the config where to copy the info
  51104. */
  51105. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51106. /**
  51107. * Serializes this Sub Surface configuration.
  51108. * @returns - An object with the serialized config.
  51109. */
  51110. serialize(): any;
  51111. /**
  51112. * Parses a anisotropy Configuration from a serialized object.
  51113. * @param source - Serialized object.
  51114. * @param scene Defines the scene we are parsing for
  51115. * @param rootUrl Defines the rootUrl to load from
  51116. */
  51117. parse(source: any, scene: Scene, rootUrl: string): void;
  51118. }
  51119. }
  51120. declare module BABYLON {
  51121. /** @hidden */
  51122. export var pbrFragmentDeclaration: {
  51123. name: string;
  51124. shader: string;
  51125. };
  51126. }
  51127. declare module BABYLON {
  51128. /** @hidden */
  51129. export var pbrUboDeclaration: {
  51130. name: string;
  51131. shader: string;
  51132. };
  51133. }
  51134. declare module BABYLON {
  51135. /** @hidden */
  51136. export var pbrFragmentExtraDeclaration: {
  51137. name: string;
  51138. shader: string;
  51139. };
  51140. }
  51141. declare module BABYLON {
  51142. /** @hidden */
  51143. export var pbrFragmentSamplersDeclaration: {
  51144. name: string;
  51145. shader: string;
  51146. };
  51147. }
  51148. declare module BABYLON {
  51149. /** @hidden */
  51150. export var pbrHelperFunctions: {
  51151. name: string;
  51152. shader: string;
  51153. };
  51154. }
  51155. declare module BABYLON {
  51156. /** @hidden */
  51157. export var harmonicsFunctions: {
  51158. name: string;
  51159. shader: string;
  51160. };
  51161. }
  51162. declare module BABYLON {
  51163. /** @hidden */
  51164. export var pbrDirectLightingSetupFunctions: {
  51165. name: string;
  51166. shader: string;
  51167. };
  51168. }
  51169. declare module BABYLON {
  51170. /** @hidden */
  51171. export var pbrDirectLightingFalloffFunctions: {
  51172. name: string;
  51173. shader: string;
  51174. };
  51175. }
  51176. declare module BABYLON {
  51177. /** @hidden */
  51178. export var pbrBRDFFunctions: {
  51179. name: string;
  51180. shader: string;
  51181. };
  51182. }
  51183. declare module BABYLON {
  51184. /** @hidden */
  51185. export var pbrDirectLightingFunctions: {
  51186. name: string;
  51187. shader: string;
  51188. };
  51189. }
  51190. declare module BABYLON {
  51191. /** @hidden */
  51192. export var pbrIBLFunctions: {
  51193. name: string;
  51194. shader: string;
  51195. };
  51196. }
  51197. declare module BABYLON {
  51198. /** @hidden */
  51199. export var pbrDebug: {
  51200. name: string;
  51201. shader: string;
  51202. };
  51203. }
  51204. declare module BABYLON {
  51205. /** @hidden */
  51206. export var pbrPixelShader: {
  51207. name: string;
  51208. shader: string;
  51209. };
  51210. }
  51211. declare module BABYLON {
  51212. /** @hidden */
  51213. export var pbrVertexDeclaration: {
  51214. name: string;
  51215. shader: string;
  51216. };
  51217. }
  51218. declare module BABYLON {
  51219. /** @hidden */
  51220. export var pbrVertexShader: {
  51221. name: string;
  51222. shader: string;
  51223. };
  51224. }
  51225. declare module BABYLON {
  51226. /**
  51227. * Manages the defines for the PBR Material.
  51228. * @hidden
  51229. */
  51230. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51231. PBR: boolean;
  51232. MAINUV1: boolean;
  51233. MAINUV2: boolean;
  51234. UV1: boolean;
  51235. UV2: boolean;
  51236. ALBEDO: boolean;
  51237. GAMMAALBEDO: boolean;
  51238. ALBEDODIRECTUV: number;
  51239. VERTEXCOLOR: boolean;
  51240. AMBIENT: boolean;
  51241. AMBIENTDIRECTUV: number;
  51242. AMBIENTINGRAYSCALE: boolean;
  51243. OPACITY: boolean;
  51244. VERTEXALPHA: boolean;
  51245. OPACITYDIRECTUV: number;
  51246. OPACITYRGB: boolean;
  51247. ALPHATEST: boolean;
  51248. DEPTHPREPASS: boolean;
  51249. ALPHABLEND: boolean;
  51250. ALPHAFROMALBEDO: boolean;
  51251. ALPHATESTVALUE: string;
  51252. SPECULAROVERALPHA: boolean;
  51253. RADIANCEOVERALPHA: boolean;
  51254. ALPHAFRESNEL: boolean;
  51255. LINEARALPHAFRESNEL: boolean;
  51256. PREMULTIPLYALPHA: boolean;
  51257. EMISSIVE: boolean;
  51258. EMISSIVEDIRECTUV: number;
  51259. REFLECTIVITY: boolean;
  51260. REFLECTIVITYDIRECTUV: number;
  51261. SPECULARTERM: boolean;
  51262. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51263. MICROSURFACEAUTOMATIC: boolean;
  51264. LODBASEDMICROSFURACE: boolean;
  51265. MICROSURFACEMAP: boolean;
  51266. MICROSURFACEMAPDIRECTUV: number;
  51267. METALLICWORKFLOW: boolean;
  51268. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51269. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51270. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51271. AOSTOREINMETALMAPRED: boolean;
  51272. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51273. ENVIRONMENTBRDF: boolean;
  51274. ENVIRONMENTBRDF_RGBD: boolean;
  51275. NORMAL: boolean;
  51276. TANGENT: boolean;
  51277. BUMP: boolean;
  51278. BUMPDIRECTUV: number;
  51279. OBJECTSPACE_NORMALMAP: boolean;
  51280. PARALLAX: boolean;
  51281. PARALLAXOCCLUSION: boolean;
  51282. NORMALXYSCALE: boolean;
  51283. LIGHTMAP: boolean;
  51284. LIGHTMAPDIRECTUV: number;
  51285. USELIGHTMAPASSHADOWMAP: boolean;
  51286. GAMMALIGHTMAP: boolean;
  51287. RGBDLIGHTMAP: boolean;
  51288. REFLECTION: boolean;
  51289. REFLECTIONMAP_3D: boolean;
  51290. REFLECTIONMAP_SPHERICAL: boolean;
  51291. REFLECTIONMAP_PLANAR: boolean;
  51292. REFLECTIONMAP_CUBIC: boolean;
  51293. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51294. REFLECTIONMAP_PROJECTION: boolean;
  51295. REFLECTIONMAP_SKYBOX: boolean;
  51296. REFLECTIONMAP_EXPLICIT: boolean;
  51297. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51298. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51299. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51300. INVERTCUBICMAP: boolean;
  51301. USESPHERICALFROMREFLECTIONMAP: boolean;
  51302. USEIRRADIANCEMAP: boolean;
  51303. SPHERICAL_HARMONICS: boolean;
  51304. USESPHERICALINVERTEX: boolean;
  51305. REFLECTIONMAP_OPPOSITEZ: boolean;
  51306. LODINREFLECTIONALPHA: boolean;
  51307. GAMMAREFLECTION: boolean;
  51308. RGBDREFLECTION: boolean;
  51309. LINEARSPECULARREFLECTION: boolean;
  51310. RADIANCEOCCLUSION: boolean;
  51311. HORIZONOCCLUSION: boolean;
  51312. INSTANCES: boolean;
  51313. NUM_BONE_INFLUENCERS: number;
  51314. BonesPerMesh: number;
  51315. BONETEXTURE: boolean;
  51316. NONUNIFORMSCALING: boolean;
  51317. MORPHTARGETS: boolean;
  51318. MORPHTARGETS_NORMAL: boolean;
  51319. MORPHTARGETS_TANGENT: boolean;
  51320. MORPHTARGETS_UV: boolean;
  51321. NUM_MORPH_INFLUENCERS: number;
  51322. IMAGEPROCESSING: boolean;
  51323. VIGNETTE: boolean;
  51324. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51325. VIGNETTEBLENDMODEOPAQUE: boolean;
  51326. TONEMAPPING: boolean;
  51327. TONEMAPPING_ACES: boolean;
  51328. CONTRAST: boolean;
  51329. COLORCURVES: boolean;
  51330. COLORGRADING: boolean;
  51331. COLORGRADING3D: boolean;
  51332. SAMPLER3DGREENDEPTH: boolean;
  51333. SAMPLER3DBGRMAP: boolean;
  51334. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51335. EXPOSURE: boolean;
  51336. MULTIVIEW: boolean;
  51337. USEPHYSICALLIGHTFALLOFF: boolean;
  51338. USEGLTFLIGHTFALLOFF: boolean;
  51339. TWOSIDEDLIGHTING: boolean;
  51340. SHADOWFLOAT: boolean;
  51341. CLIPPLANE: boolean;
  51342. CLIPPLANE2: boolean;
  51343. CLIPPLANE3: boolean;
  51344. CLIPPLANE4: boolean;
  51345. CLIPPLANE5: boolean;
  51346. CLIPPLANE6: boolean;
  51347. POINTSIZE: boolean;
  51348. FOG: boolean;
  51349. LOGARITHMICDEPTH: boolean;
  51350. FORCENORMALFORWARD: boolean;
  51351. SPECULARAA: boolean;
  51352. CLEARCOAT: boolean;
  51353. CLEARCOAT_DEFAULTIOR: boolean;
  51354. CLEARCOAT_TEXTURE: boolean;
  51355. CLEARCOAT_TEXTUREDIRECTUV: number;
  51356. CLEARCOAT_BUMP: boolean;
  51357. CLEARCOAT_BUMPDIRECTUV: number;
  51358. CLEARCOAT_TINT: boolean;
  51359. CLEARCOAT_TINT_TEXTURE: boolean;
  51360. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51361. ANISOTROPIC: boolean;
  51362. ANISOTROPIC_TEXTURE: boolean;
  51363. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51364. BRDF_V_HEIGHT_CORRELATED: boolean;
  51365. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51366. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51367. SHEEN: boolean;
  51368. SHEEN_TEXTURE: boolean;
  51369. SHEEN_TEXTUREDIRECTUV: number;
  51370. SHEEN_LINKWITHALBEDO: boolean;
  51371. SHEEN_ROUGHNESS: boolean;
  51372. SHEEN_ALBEDOSCALING: boolean;
  51373. SUBSURFACE: boolean;
  51374. SS_REFRACTION: boolean;
  51375. SS_TRANSLUCENCY: boolean;
  51376. SS_SCATERRING: boolean;
  51377. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51378. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51379. SS_REFRACTIONMAP_3D: boolean;
  51380. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51381. SS_LODINREFRACTIONALPHA: boolean;
  51382. SS_GAMMAREFRACTION: boolean;
  51383. SS_RGBDREFRACTION: boolean;
  51384. SS_LINEARSPECULARREFRACTION: boolean;
  51385. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51386. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51387. UNLIT: boolean;
  51388. DEBUGMODE: number;
  51389. /**
  51390. * Initializes the PBR Material defines.
  51391. */
  51392. constructor();
  51393. /**
  51394. * Resets the PBR Material defines.
  51395. */
  51396. reset(): void;
  51397. }
  51398. /**
  51399. * The Physically based material base class of BJS.
  51400. *
  51401. * This offers the main features of a standard PBR material.
  51402. * For more information, please refer to the documentation :
  51403. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51404. */
  51405. export abstract class PBRBaseMaterial extends PushMaterial {
  51406. /**
  51407. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51408. */
  51409. static readonly PBRMATERIAL_OPAQUE: number;
  51410. /**
  51411. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51412. */
  51413. static readonly PBRMATERIAL_ALPHATEST: number;
  51414. /**
  51415. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51416. */
  51417. static readonly PBRMATERIAL_ALPHABLEND: number;
  51418. /**
  51419. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51420. * They are also discarded below the alpha cutoff threshold to improve performances.
  51421. */
  51422. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51423. /**
  51424. * Defines the default value of how much AO map is occluding the analytical lights
  51425. * (point spot...).
  51426. */
  51427. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51428. /**
  51429. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51430. */
  51431. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51432. /**
  51433. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51434. * to enhance interoperability with other engines.
  51435. */
  51436. static readonly LIGHTFALLOFF_GLTF: number;
  51437. /**
  51438. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51439. * to enhance interoperability with other materials.
  51440. */
  51441. static readonly LIGHTFALLOFF_STANDARD: number;
  51442. /**
  51443. * Intensity of the direct lights e.g. the four lights available in your scene.
  51444. * This impacts both the direct diffuse and specular highlights.
  51445. */
  51446. protected _directIntensity: number;
  51447. /**
  51448. * Intensity of the emissive part of the material.
  51449. * This helps controlling the emissive effect without modifying the emissive color.
  51450. */
  51451. protected _emissiveIntensity: number;
  51452. /**
  51453. * Intensity of the environment e.g. how much the environment will light the object
  51454. * either through harmonics for rough material or through the refelction for shiny ones.
  51455. */
  51456. protected _environmentIntensity: number;
  51457. /**
  51458. * This is a special control allowing the reduction of the specular highlights coming from the
  51459. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51460. */
  51461. protected _specularIntensity: number;
  51462. /**
  51463. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51464. */
  51465. private _lightingInfos;
  51466. /**
  51467. * Debug Control allowing disabling the bump map on this material.
  51468. */
  51469. protected _disableBumpMap: boolean;
  51470. /**
  51471. * AKA Diffuse Texture in standard nomenclature.
  51472. */
  51473. protected _albedoTexture: Nullable<BaseTexture>;
  51474. /**
  51475. * AKA Occlusion Texture in other nomenclature.
  51476. */
  51477. protected _ambientTexture: Nullable<BaseTexture>;
  51478. /**
  51479. * AKA Occlusion Texture Intensity in other nomenclature.
  51480. */
  51481. protected _ambientTextureStrength: number;
  51482. /**
  51483. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51484. * 1 means it completely occludes it
  51485. * 0 mean it has no impact
  51486. */
  51487. protected _ambientTextureImpactOnAnalyticalLights: number;
  51488. /**
  51489. * Stores the alpha values in a texture.
  51490. */
  51491. protected _opacityTexture: Nullable<BaseTexture>;
  51492. /**
  51493. * Stores the reflection values in a texture.
  51494. */
  51495. protected _reflectionTexture: Nullable<BaseTexture>;
  51496. /**
  51497. * Stores the emissive values in a texture.
  51498. */
  51499. protected _emissiveTexture: Nullable<BaseTexture>;
  51500. /**
  51501. * AKA Specular texture in other nomenclature.
  51502. */
  51503. protected _reflectivityTexture: Nullable<BaseTexture>;
  51504. /**
  51505. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51506. */
  51507. protected _metallicTexture: Nullable<BaseTexture>;
  51508. /**
  51509. * Specifies the metallic scalar of the metallic/roughness workflow.
  51510. * Can also be used to scale the metalness values of the metallic texture.
  51511. */
  51512. protected _metallic: Nullable<number>;
  51513. /**
  51514. * Specifies the roughness scalar of the metallic/roughness workflow.
  51515. * Can also be used to scale the roughness values of the metallic texture.
  51516. */
  51517. protected _roughness: Nullable<number>;
  51518. /**
  51519. * Specifies the an F0 factor to help configuring the material F0.
  51520. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51521. * to 0.5 the previously hard coded value stays the same.
  51522. * Can also be used to scale the F0 values of the metallic texture.
  51523. */
  51524. protected _metallicF0Factor: number;
  51525. /**
  51526. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51527. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51528. * your expectation as it multiplies with the texture data.
  51529. */
  51530. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51531. /**
  51532. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51533. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51534. */
  51535. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51536. /**
  51537. * Stores surface normal data used to displace a mesh in a texture.
  51538. */
  51539. protected _bumpTexture: Nullable<BaseTexture>;
  51540. /**
  51541. * Stores the pre-calculated light information of a mesh in a texture.
  51542. */
  51543. protected _lightmapTexture: Nullable<BaseTexture>;
  51544. /**
  51545. * The color of a material in ambient lighting.
  51546. */
  51547. protected _ambientColor: Color3;
  51548. /**
  51549. * AKA Diffuse Color in other nomenclature.
  51550. */
  51551. protected _albedoColor: Color3;
  51552. /**
  51553. * AKA Specular Color in other nomenclature.
  51554. */
  51555. protected _reflectivityColor: Color3;
  51556. /**
  51557. * The color applied when light is reflected from a material.
  51558. */
  51559. protected _reflectionColor: Color3;
  51560. /**
  51561. * The color applied when light is emitted from a material.
  51562. */
  51563. protected _emissiveColor: Color3;
  51564. /**
  51565. * AKA Glossiness in other nomenclature.
  51566. */
  51567. protected _microSurface: number;
  51568. /**
  51569. * Specifies that the material will use the light map as a show map.
  51570. */
  51571. protected _useLightmapAsShadowmap: boolean;
  51572. /**
  51573. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51574. * makes the reflect vector face the model (under horizon).
  51575. */
  51576. protected _useHorizonOcclusion: boolean;
  51577. /**
  51578. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51579. * too much the area relying on ambient texture to define their ambient occlusion.
  51580. */
  51581. protected _useRadianceOcclusion: boolean;
  51582. /**
  51583. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51584. */
  51585. protected _useAlphaFromAlbedoTexture: boolean;
  51586. /**
  51587. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51588. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51589. */
  51590. protected _useSpecularOverAlpha: boolean;
  51591. /**
  51592. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51593. */
  51594. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51595. /**
  51596. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51597. */
  51598. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51599. /**
  51600. * Specifies if the metallic texture contains the roughness information in its green channel.
  51601. */
  51602. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51603. /**
  51604. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51605. */
  51606. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51607. /**
  51608. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51609. */
  51610. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51611. /**
  51612. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51613. */
  51614. protected _useAmbientInGrayScale: boolean;
  51615. /**
  51616. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51617. * The material will try to infer what glossiness each pixel should be.
  51618. */
  51619. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51620. /**
  51621. * Defines the falloff type used in this material.
  51622. * It by default is Physical.
  51623. */
  51624. protected _lightFalloff: number;
  51625. /**
  51626. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51627. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51628. */
  51629. protected _useRadianceOverAlpha: boolean;
  51630. /**
  51631. * Allows using an object space normal map (instead of tangent space).
  51632. */
  51633. protected _useObjectSpaceNormalMap: boolean;
  51634. /**
  51635. * Allows using the bump map in parallax mode.
  51636. */
  51637. protected _useParallax: boolean;
  51638. /**
  51639. * Allows using the bump map in parallax occlusion mode.
  51640. */
  51641. protected _useParallaxOcclusion: boolean;
  51642. /**
  51643. * Controls the scale bias of the parallax mode.
  51644. */
  51645. protected _parallaxScaleBias: number;
  51646. /**
  51647. * If sets to true, disables all the lights affecting the material.
  51648. */
  51649. protected _disableLighting: boolean;
  51650. /**
  51651. * Number of Simultaneous lights allowed on the material.
  51652. */
  51653. protected _maxSimultaneousLights: number;
  51654. /**
  51655. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51656. */
  51657. protected _invertNormalMapX: boolean;
  51658. /**
  51659. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51660. */
  51661. protected _invertNormalMapY: boolean;
  51662. /**
  51663. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51664. */
  51665. protected _twoSidedLighting: boolean;
  51666. /**
  51667. * Defines the alpha limits in alpha test mode.
  51668. */
  51669. protected _alphaCutOff: number;
  51670. /**
  51671. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51672. */
  51673. protected _forceAlphaTest: boolean;
  51674. /**
  51675. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51676. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51677. */
  51678. protected _useAlphaFresnel: boolean;
  51679. /**
  51680. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51681. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51682. */
  51683. protected _useLinearAlphaFresnel: boolean;
  51684. /**
  51685. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51686. * from cos thetav and roughness:
  51687. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51688. */
  51689. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51690. /**
  51691. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51692. */
  51693. protected _forceIrradianceInFragment: boolean;
  51694. /**
  51695. * Force normal to face away from face.
  51696. */
  51697. protected _forceNormalForward: boolean;
  51698. /**
  51699. * Enables specular anti aliasing in the PBR shader.
  51700. * It will both interacts on the Geometry for analytical and IBL lighting.
  51701. * It also prefilter the roughness map based on the bump values.
  51702. */
  51703. protected _enableSpecularAntiAliasing: boolean;
  51704. /**
  51705. * Default configuration related to image processing available in the PBR Material.
  51706. */
  51707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51708. /**
  51709. * Keep track of the image processing observer to allow dispose and replace.
  51710. */
  51711. private _imageProcessingObserver;
  51712. /**
  51713. * Attaches a new image processing configuration to the PBR Material.
  51714. * @param configuration
  51715. */
  51716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51717. /**
  51718. * Stores the available render targets.
  51719. */
  51720. private _renderTargets;
  51721. /**
  51722. * Sets the global ambient color for the material used in lighting calculations.
  51723. */
  51724. private _globalAmbientColor;
  51725. /**
  51726. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51727. */
  51728. private _useLogarithmicDepth;
  51729. /**
  51730. * If set to true, no lighting calculations will be applied.
  51731. */
  51732. private _unlit;
  51733. private _debugMode;
  51734. /**
  51735. * @hidden
  51736. * This is reserved for the inspector.
  51737. * Defines the material debug mode.
  51738. * It helps seeing only some components of the material while troubleshooting.
  51739. */
  51740. debugMode: number;
  51741. /**
  51742. * @hidden
  51743. * This is reserved for the inspector.
  51744. * Specify from where on screen the debug mode should start.
  51745. * The value goes from -1 (full screen) to 1 (not visible)
  51746. * It helps with side by side comparison against the final render
  51747. * This defaults to -1
  51748. */
  51749. private debugLimit;
  51750. /**
  51751. * @hidden
  51752. * This is reserved for the inspector.
  51753. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51754. * You can use the factor to better multiply the final value.
  51755. */
  51756. private debugFactor;
  51757. /**
  51758. * Defines the clear coat layer parameters for the material.
  51759. */
  51760. readonly clearCoat: PBRClearCoatConfiguration;
  51761. /**
  51762. * Defines the anisotropic parameters for the material.
  51763. */
  51764. readonly anisotropy: PBRAnisotropicConfiguration;
  51765. /**
  51766. * Defines the BRDF parameters for the material.
  51767. */
  51768. readonly brdf: PBRBRDFConfiguration;
  51769. /**
  51770. * Defines the Sheen parameters for the material.
  51771. */
  51772. readonly sheen: PBRSheenConfiguration;
  51773. /**
  51774. * Defines the SubSurface parameters for the material.
  51775. */
  51776. readonly subSurface: PBRSubSurfaceConfiguration;
  51777. /**
  51778. * Custom callback helping to override the default shader used in the material.
  51779. */
  51780. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51781. protected _rebuildInParallel: boolean;
  51782. /**
  51783. * Instantiates a new PBRMaterial instance.
  51784. *
  51785. * @param name The material name
  51786. * @param scene The scene the material will be use in.
  51787. */
  51788. constructor(name: string, scene: Scene);
  51789. /**
  51790. * Gets a boolean indicating that current material needs to register RTT
  51791. */
  51792. get hasRenderTargetTextures(): boolean;
  51793. /**
  51794. * Gets the name of the material class.
  51795. */
  51796. getClassName(): string;
  51797. /**
  51798. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51799. */
  51800. get useLogarithmicDepth(): boolean;
  51801. /**
  51802. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51803. */
  51804. set useLogarithmicDepth(value: boolean);
  51805. /**
  51806. * Returns true if alpha blending should be disabled.
  51807. */
  51808. protected get _disableAlphaBlending(): boolean;
  51809. /**
  51810. * Specifies whether or not this material should be rendered in alpha blend mode.
  51811. */
  51812. needAlphaBlending(): boolean;
  51813. /**
  51814. * Specifies whether or not this material should be rendered in alpha test mode.
  51815. */
  51816. needAlphaTesting(): boolean;
  51817. /**
  51818. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51819. */
  51820. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51821. /**
  51822. * Gets the texture used for the alpha test.
  51823. */
  51824. getAlphaTestTexture(): Nullable<BaseTexture>;
  51825. /**
  51826. * Specifies that the submesh is ready to be used.
  51827. * @param mesh - BJS mesh.
  51828. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51829. * @param useInstances - Specifies that instances should be used.
  51830. * @returns - boolean indicating that the submesh is ready or not.
  51831. */
  51832. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51833. /**
  51834. * Specifies if the material uses metallic roughness workflow.
  51835. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51836. */
  51837. isMetallicWorkflow(): boolean;
  51838. private _prepareEffect;
  51839. private _prepareDefines;
  51840. /**
  51841. * Force shader compilation
  51842. */
  51843. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51844. /**
  51845. * Initializes the uniform buffer layout for the shader.
  51846. */
  51847. buildUniformLayout(): void;
  51848. /**
  51849. * Unbinds the material from the mesh
  51850. */
  51851. unbind(): void;
  51852. /**
  51853. * Binds the submesh data.
  51854. * @param world - The world matrix.
  51855. * @param mesh - The BJS mesh.
  51856. * @param subMesh - A submesh of the BJS mesh.
  51857. */
  51858. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51859. /**
  51860. * Returns the animatable textures.
  51861. * @returns - Array of animatable textures.
  51862. */
  51863. getAnimatables(): IAnimatable[];
  51864. /**
  51865. * Returns the texture used for reflections.
  51866. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51867. */
  51868. private _getReflectionTexture;
  51869. /**
  51870. * Returns an array of the actively used textures.
  51871. * @returns - Array of BaseTextures
  51872. */
  51873. getActiveTextures(): BaseTexture[];
  51874. /**
  51875. * Checks to see if a texture is used in the material.
  51876. * @param texture - Base texture to use.
  51877. * @returns - Boolean specifying if a texture is used in the material.
  51878. */
  51879. hasTexture(texture: BaseTexture): boolean;
  51880. /**
  51881. * Disposes the resources of the material.
  51882. * @param forceDisposeEffect - Forces the disposal of effects.
  51883. * @param forceDisposeTextures - Forces the disposal of all textures.
  51884. */
  51885. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51886. }
  51887. }
  51888. declare module BABYLON {
  51889. /**
  51890. * The Physically based material of BJS.
  51891. *
  51892. * This offers the main features of a standard PBR material.
  51893. * For more information, please refer to the documentation :
  51894. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51895. */
  51896. export class PBRMaterial extends PBRBaseMaterial {
  51897. /**
  51898. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51899. */
  51900. static readonly PBRMATERIAL_OPAQUE: number;
  51901. /**
  51902. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51903. */
  51904. static readonly PBRMATERIAL_ALPHATEST: number;
  51905. /**
  51906. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51907. */
  51908. static readonly PBRMATERIAL_ALPHABLEND: number;
  51909. /**
  51910. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51911. * They are also discarded below the alpha cutoff threshold to improve performances.
  51912. */
  51913. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51914. /**
  51915. * Defines the default value of how much AO map is occluding the analytical lights
  51916. * (point spot...).
  51917. */
  51918. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51919. /**
  51920. * Intensity of the direct lights e.g. the four lights available in your scene.
  51921. * This impacts both the direct diffuse and specular highlights.
  51922. */
  51923. directIntensity: number;
  51924. /**
  51925. * Intensity of the emissive part of the material.
  51926. * This helps controlling the emissive effect without modifying the emissive color.
  51927. */
  51928. emissiveIntensity: number;
  51929. /**
  51930. * Intensity of the environment e.g. how much the environment will light the object
  51931. * either through harmonics for rough material or through the refelction for shiny ones.
  51932. */
  51933. environmentIntensity: number;
  51934. /**
  51935. * This is a special control allowing the reduction of the specular highlights coming from the
  51936. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51937. */
  51938. specularIntensity: number;
  51939. /**
  51940. * Debug Control allowing disabling the bump map on this material.
  51941. */
  51942. disableBumpMap: boolean;
  51943. /**
  51944. * AKA Diffuse Texture in standard nomenclature.
  51945. */
  51946. albedoTexture: BaseTexture;
  51947. /**
  51948. * AKA Occlusion Texture in other nomenclature.
  51949. */
  51950. ambientTexture: BaseTexture;
  51951. /**
  51952. * AKA Occlusion Texture Intensity in other nomenclature.
  51953. */
  51954. ambientTextureStrength: number;
  51955. /**
  51956. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51957. * 1 means it completely occludes it
  51958. * 0 mean it has no impact
  51959. */
  51960. ambientTextureImpactOnAnalyticalLights: number;
  51961. /**
  51962. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51963. */
  51964. opacityTexture: BaseTexture;
  51965. /**
  51966. * Stores the reflection values in a texture.
  51967. */
  51968. reflectionTexture: Nullable<BaseTexture>;
  51969. /**
  51970. * Stores the emissive values in a texture.
  51971. */
  51972. emissiveTexture: BaseTexture;
  51973. /**
  51974. * AKA Specular texture in other nomenclature.
  51975. */
  51976. reflectivityTexture: BaseTexture;
  51977. /**
  51978. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51979. */
  51980. metallicTexture: BaseTexture;
  51981. /**
  51982. * Specifies the metallic scalar of the metallic/roughness workflow.
  51983. * Can also be used to scale the metalness values of the metallic texture.
  51984. */
  51985. metallic: Nullable<number>;
  51986. /**
  51987. * Specifies the roughness scalar of the metallic/roughness workflow.
  51988. * Can also be used to scale the roughness values of the metallic texture.
  51989. */
  51990. roughness: Nullable<number>;
  51991. /**
  51992. * Specifies the an F0 factor to help configuring the material F0.
  51993. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51994. * to 0.5 the previously hard coded value stays the same.
  51995. * Can also be used to scale the F0 values of the metallic texture.
  51996. */
  51997. metallicF0Factor: number;
  51998. /**
  51999. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52000. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52001. * your expectation as it multiplies with the texture data.
  52002. */
  52003. useMetallicF0FactorFromMetallicTexture: boolean;
  52004. /**
  52005. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52006. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52007. */
  52008. microSurfaceTexture: BaseTexture;
  52009. /**
  52010. * Stores surface normal data used to displace a mesh in a texture.
  52011. */
  52012. bumpTexture: BaseTexture;
  52013. /**
  52014. * Stores the pre-calculated light information of a mesh in a texture.
  52015. */
  52016. lightmapTexture: BaseTexture;
  52017. /**
  52018. * Stores the refracted light information in a texture.
  52019. */
  52020. get refractionTexture(): Nullable<BaseTexture>;
  52021. set refractionTexture(value: Nullable<BaseTexture>);
  52022. /**
  52023. * The color of a material in ambient lighting.
  52024. */
  52025. ambientColor: Color3;
  52026. /**
  52027. * AKA Diffuse Color in other nomenclature.
  52028. */
  52029. albedoColor: Color3;
  52030. /**
  52031. * AKA Specular Color in other nomenclature.
  52032. */
  52033. reflectivityColor: Color3;
  52034. /**
  52035. * The color reflected from the material.
  52036. */
  52037. reflectionColor: Color3;
  52038. /**
  52039. * The color emitted from the material.
  52040. */
  52041. emissiveColor: Color3;
  52042. /**
  52043. * AKA Glossiness in other nomenclature.
  52044. */
  52045. microSurface: number;
  52046. /**
  52047. * source material index of refraction (IOR)' / 'destination material IOR.
  52048. */
  52049. get indexOfRefraction(): number;
  52050. set indexOfRefraction(value: number);
  52051. /**
  52052. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52053. */
  52054. get invertRefractionY(): boolean;
  52055. set invertRefractionY(value: boolean);
  52056. /**
  52057. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52058. * Materials half opaque for instance using refraction could benefit from this control.
  52059. */
  52060. get linkRefractionWithTransparency(): boolean;
  52061. set linkRefractionWithTransparency(value: boolean);
  52062. /**
  52063. * If true, the light map contains occlusion information instead of lighting info.
  52064. */
  52065. useLightmapAsShadowmap: boolean;
  52066. /**
  52067. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52068. */
  52069. useAlphaFromAlbedoTexture: boolean;
  52070. /**
  52071. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52072. */
  52073. forceAlphaTest: boolean;
  52074. /**
  52075. * Defines the alpha limits in alpha test mode.
  52076. */
  52077. alphaCutOff: number;
  52078. /**
  52079. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52080. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52081. */
  52082. useSpecularOverAlpha: boolean;
  52083. /**
  52084. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52085. */
  52086. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52087. /**
  52088. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52089. */
  52090. useRoughnessFromMetallicTextureAlpha: boolean;
  52091. /**
  52092. * Specifies if the metallic texture contains the roughness information in its green channel.
  52093. */
  52094. useRoughnessFromMetallicTextureGreen: boolean;
  52095. /**
  52096. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52097. */
  52098. useMetallnessFromMetallicTextureBlue: boolean;
  52099. /**
  52100. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52101. */
  52102. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52103. /**
  52104. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52105. */
  52106. useAmbientInGrayScale: boolean;
  52107. /**
  52108. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52109. * The material will try to infer what glossiness each pixel should be.
  52110. */
  52111. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52112. /**
  52113. * BJS is using an harcoded light falloff based on a manually sets up range.
  52114. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52115. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52116. */
  52117. get usePhysicalLightFalloff(): boolean;
  52118. /**
  52119. * BJS is using an harcoded light falloff based on a manually sets up range.
  52120. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52121. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52122. */
  52123. set usePhysicalLightFalloff(value: boolean);
  52124. /**
  52125. * In order to support the falloff compatibility with gltf, a special mode has been added
  52126. * to reproduce the gltf light falloff.
  52127. */
  52128. get useGLTFLightFalloff(): boolean;
  52129. /**
  52130. * In order to support the falloff compatibility with gltf, a special mode has been added
  52131. * to reproduce the gltf light falloff.
  52132. */
  52133. set useGLTFLightFalloff(value: boolean);
  52134. /**
  52135. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52136. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52137. */
  52138. useRadianceOverAlpha: boolean;
  52139. /**
  52140. * Allows using an object space normal map (instead of tangent space).
  52141. */
  52142. useObjectSpaceNormalMap: boolean;
  52143. /**
  52144. * Allows using the bump map in parallax mode.
  52145. */
  52146. useParallax: boolean;
  52147. /**
  52148. * Allows using the bump map in parallax occlusion mode.
  52149. */
  52150. useParallaxOcclusion: boolean;
  52151. /**
  52152. * Controls the scale bias of the parallax mode.
  52153. */
  52154. parallaxScaleBias: number;
  52155. /**
  52156. * If sets to true, disables all the lights affecting the material.
  52157. */
  52158. disableLighting: boolean;
  52159. /**
  52160. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52161. */
  52162. forceIrradianceInFragment: boolean;
  52163. /**
  52164. * Number of Simultaneous lights allowed on the material.
  52165. */
  52166. maxSimultaneousLights: number;
  52167. /**
  52168. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52169. */
  52170. invertNormalMapX: boolean;
  52171. /**
  52172. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52173. */
  52174. invertNormalMapY: boolean;
  52175. /**
  52176. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52177. */
  52178. twoSidedLighting: boolean;
  52179. /**
  52180. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52181. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52182. */
  52183. useAlphaFresnel: boolean;
  52184. /**
  52185. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52186. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52187. */
  52188. useLinearAlphaFresnel: boolean;
  52189. /**
  52190. * Let user defines the brdf lookup texture used for IBL.
  52191. * A default 8bit version is embedded but you could point at :
  52192. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52193. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52194. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52195. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52196. */
  52197. environmentBRDFTexture: Nullable<BaseTexture>;
  52198. /**
  52199. * Force normal to face away from face.
  52200. */
  52201. forceNormalForward: boolean;
  52202. /**
  52203. * Enables specular anti aliasing in the PBR shader.
  52204. * It will both interacts on the Geometry for analytical and IBL lighting.
  52205. * It also prefilter the roughness map based on the bump values.
  52206. */
  52207. enableSpecularAntiAliasing: boolean;
  52208. /**
  52209. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52210. * makes the reflect vector face the model (under horizon).
  52211. */
  52212. useHorizonOcclusion: boolean;
  52213. /**
  52214. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52215. * too much the area relying on ambient texture to define their ambient occlusion.
  52216. */
  52217. useRadianceOcclusion: boolean;
  52218. /**
  52219. * If set to true, no lighting calculations will be applied.
  52220. */
  52221. unlit: boolean;
  52222. /**
  52223. * Gets the image processing configuration used either in this material.
  52224. */
  52225. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52226. /**
  52227. * Sets the Default image processing configuration used either in the this material.
  52228. *
  52229. * If sets to null, the scene one is in use.
  52230. */
  52231. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52232. /**
  52233. * Gets wether the color curves effect is enabled.
  52234. */
  52235. get cameraColorCurvesEnabled(): boolean;
  52236. /**
  52237. * Sets wether the color curves effect is enabled.
  52238. */
  52239. set cameraColorCurvesEnabled(value: boolean);
  52240. /**
  52241. * Gets wether the color grading effect is enabled.
  52242. */
  52243. get cameraColorGradingEnabled(): boolean;
  52244. /**
  52245. * Gets wether the color grading effect is enabled.
  52246. */
  52247. set cameraColorGradingEnabled(value: boolean);
  52248. /**
  52249. * Gets wether tonemapping is enabled or not.
  52250. */
  52251. get cameraToneMappingEnabled(): boolean;
  52252. /**
  52253. * Sets wether tonemapping is enabled or not
  52254. */
  52255. set cameraToneMappingEnabled(value: boolean);
  52256. /**
  52257. * The camera exposure used on this material.
  52258. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52259. * This corresponds to a photographic exposure.
  52260. */
  52261. get cameraExposure(): number;
  52262. /**
  52263. * The camera exposure used on this material.
  52264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52265. * This corresponds to a photographic exposure.
  52266. */
  52267. set cameraExposure(value: number);
  52268. /**
  52269. * Gets The camera contrast used on this material.
  52270. */
  52271. get cameraContrast(): number;
  52272. /**
  52273. * Sets The camera contrast used on this material.
  52274. */
  52275. set cameraContrast(value: number);
  52276. /**
  52277. * Gets the Color Grading 2D Lookup Texture.
  52278. */
  52279. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52280. /**
  52281. * Sets the Color Grading 2D Lookup Texture.
  52282. */
  52283. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52284. /**
  52285. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52286. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52287. * 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;
  52288. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52289. */
  52290. get cameraColorCurves(): Nullable<ColorCurves>;
  52291. /**
  52292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52294. * 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;
  52295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52296. */
  52297. set cameraColorCurves(value: Nullable<ColorCurves>);
  52298. /**
  52299. * Instantiates a new PBRMaterial instance.
  52300. *
  52301. * @param name The material name
  52302. * @param scene The scene the material will be use in.
  52303. */
  52304. constructor(name: string, scene: Scene);
  52305. /**
  52306. * Returns the name of this material class.
  52307. */
  52308. getClassName(): string;
  52309. /**
  52310. * Makes a duplicate of the current material.
  52311. * @param name - name to use for the new material.
  52312. */
  52313. clone(name: string): PBRMaterial;
  52314. /**
  52315. * Serializes this PBR Material.
  52316. * @returns - An object with the serialized material.
  52317. */
  52318. serialize(): any;
  52319. /**
  52320. * Parses a PBR Material from a serialized object.
  52321. * @param source - Serialized object.
  52322. * @param scene - BJS scene instance.
  52323. * @param rootUrl - url for the scene object
  52324. * @returns - PBRMaterial
  52325. */
  52326. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52327. }
  52328. }
  52329. declare module BABYLON {
  52330. /**
  52331. * Direct draw surface info
  52332. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52333. */
  52334. export interface DDSInfo {
  52335. /**
  52336. * Width of the texture
  52337. */
  52338. width: number;
  52339. /**
  52340. * Width of the texture
  52341. */
  52342. height: number;
  52343. /**
  52344. * Number of Mipmaps for the texture
  52345. * @see https://en.wikipedia.org/wiki/Mipmap
  52346. */
  52347. mipmapCount: number;
  52348. /**
  52349. * If the textures format is a known fourCC format
  52350. * @see https://www.fourcc.org/
  52351. */
  52352. isFourCC: boolean;
  52353. /**
  52354. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52355. */
  52356. isRGB: boolean;
  52357. /**
  52358. * If the texture is a lumincance format
  52359. */
  52360. isLuminance: boolean;
  52361. /**
  52362. * If this is a cube texture
  52363. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52364. */
  52365. isCube: boolean;
  52366. /**
  52367. * If the texture is a compressed format eg. FOURCC_DXT1
  52368. */
  52369. isCompressed: boolean;
  52370. /**
  52371. * The dxgiFormat of the texture
  52372. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52373. */
  52374. dxgiFormat: number;
  52375. /**
  52376. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52377. */
  52378. textureType: number;
  52379. /**
  52380. * Sphericle polynomial created for the dds texture
  52381. */
  52382. sphericalPolynomial?: SphericalPolynomial;
  52383. }
  52384. /**
  52385. * Class used to provide DDS decompression tools
  52386. */
  52387. export class DDSTools {
  52388. /**
  52389. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52390. */
  52391. static StoreLODInAlphaChannel: boolean;
  52392. /**
  52393. * Gets DDS information from an array buffer
  52394. * @param data defines the array buffer view to read data from
  52395. * @returns the DDS information
  52396. */
  52397. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52398. private static _FloatView;
  52399. private static _Int32View;
  52400. private static _ToHalfFloat;
  52401. private static _FromHalfFloat;
  52402. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52403. private static _GetHalfFloatRGBAArrayBuffer;
  52404. private static _GetFloatRGBAArrayBuffer;
  52405. private static _GetFloatAsUIntRGBAArrayBuffer;
  52406. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52407. private static _GetRGBAArrayBuffer;
  52408. private static _ExtractLongWordOrder;
  52409. private static _GetRGBArrayBuffer;
  52410. private static _GetLuminanceArrayBuffer;
  52411. /**
  52412. * Uploads DDS Levels to a Babylon Texture
  52413. * @hidden
  52414. */
  52415. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52416. }
  52417. interface ThinEngine {
  52418. /**
  52419. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52420. * @param rootUrl defines the url where the file to load is located
  52421. * @param scene defines the current scene
  52422. * @param lodScale defines scale to apply to the mip map selection
  52423. * @param lodOffset defines offset to apply to the mip map selection
  52424. * @param onLoad defines an optional callback raised when the texture is loaded
  52425. * @param onError defines an optional callback raised if there is an issue to load the texture
  52426. * @param format defines the format of the data
  52427. * @param forcedExtension defines the extension to use to pick the right loader
  52428. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52429. * @returns the cube texture as an InternalTexture
  52430. */
  52431. 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;
  52432. }
  52433. }
  52434. declare module BABYLON {
  52435. /**
  52436. * Implementation of the DDS Texture Loader.
  52437. * @hidden
  52438. */
  52439. export class _DDSTextureLoader implements IInternalTextureLoader {
  52440. /**
  52441. * Defines wether the loader supports cascade loading the different faces.
  52442. */
  52443. readonly supportCascades: boolean;
  52444. /**
  52445. * This returns if the loader support the current file information.
  52446. * @param extension defines the file extension of the file being loaded
  52447. * @returns true if the loader can load the specified file
  52448. */
  52449. canLoad(extension: string): boolean;
  52450. /**
  52451. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52452. * @param data contains the texture data
  52453. * @param texture defines the BabylonJS internal texture
  52454. * @param createPolynomials will be true if polynomials have been requested
  52455. * @param onLoad defines the callback to trigger once the texture is ready
  52456. * @param onError defines the callback to trigger in case of error
  52457. */
  52458. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52459. /**
  52460. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52461. * @param data contains the texture data
  52462. * @param texture defines the BabylonJS internal texture
  52463. * @param callback defines the method to call once ready to upload
  52464. */
  52465. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52466. }
  52467. }
  52468. declare module BABYLON {
  52469. /**
  52470. * Implementation of the ENV Texture Loader.
  52471. * @hidden
  52472. */
  52473. export class _ENVTextureLoader implements IInternalTextureLoader {
  52474. /**
  52475. * Defines wether the loader supports cascade loading the different faces.
  52476. */
  52477. readonly supportCascades: boolean;
  52478. /**
  52479. * This returns if the loader support the current file information.
  52480. * @param extension defines the file extension of the file being loaded
  52481. * @returns true if the loader can load the specified file
  52482. */
  52483. canLoad(extension: string): boolean;
  52484. /**
  52485. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52486. * @param data contains the texture data
  52487. * @param texture defines the BabylonJS internal texture
  52488. * @param createPolynomials will be true if polynomials have been requested
  52489. * @param onLoad defines the callback to trigger once the texture is ready
  52490. * @param onError defines the callback to trigger in case of error
  52491. */
  52492. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52493. /**
  52494. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52495. * @param data contains the texture data
  52496. * @param texture defines the BabylonJS internal texture
  52497. * @param callback defines the method to call once ready to upload
  52498. */
  52499. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52500. }
  52501. }
  52502. declare module BABYLON {
  52503. /**
  52504. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52505. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52506. */
  52507. export class KhronosTextureContainer {
  52508. /** contents of the KTX container file */
  52509. data: ArrayBufferView;
  52510. private static HEADER_LEN;
  52511. private static COMPRESSED_2D;
  52512. private static COMPRESSED_3D;
  52513. private static TEX_2D;
  52514. private static TEX_3D;
  52515. /**
  52516. * Gets the openGL type
  52517. */
  52518. glType: number;
  52519. /**
  52520. * Gets the openGL type size
  52521. */
  52522. glTypeSize: number;
  52523. /**
  52524. * Gets the openGL format
  52525. */
  52526. glFormat: number;
  52527. /**
  52528. * Gets the openGL internal format
  52529. */
  52530. glInternalFormat: number;
  52531. /**
  52532. * Gets the base internal format
  52533. */
  52534. glBaseInternalFormat: number;
  52535. /**
  52536. * Gets image width in pixel
  52537. */
  52538. pixelWidth: number;
  52539. /**
  52540. * Gets image height in pixel
  52541. */
  52542. pixelHeight: number;
  52543. /**
  52544. * Gets image depth in pixels
  52545. */
  52546. pixelDepth: number;
  52547. /**
  52548. * Gets the number of array elements
  52549. */
  52550. numberOfArrayElements: number;
  52551. /**
  52552. * Gets the number of faces
  52553. */
  52554. numberOfFaces: number;
  52555. /**
  52556. * Gets the number of mipmap levels
  52557. */
  52558. numberOfMipmapLevels: number;
  52559. /**
  52560. * Gets the bytes of key value data
  52561. */
  52562. bytesOfKeyValueData: number;
  52563. /**
  52564. * Gets the load type
  52565. */
  52566. loadType: number;
  52567. /**
  52568. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52569. */
  52570. isInvalid: boolean;
  52571. /**
  52572. * Creates a new KhronosTextureContainer
  52573. * @param data contents of the KTX container file
  52574. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52575. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52576. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52577. */
  52578. constructor(
  52579. /** contents of the KTX container file */
  52580. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52581. /**
  52582. * Uploads KTX content to a Babylon Texture.
  52583. * It is assumed that the texture has already been created & is currently bound
  52584. * @hidden
  52585. */
  52586. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52587. private _upload2DCompressedLevels;
  52588. /**
  52589. * Checks if the given data starts with a KTX file identifier.
  52590. * @param data the data to check
  52591. * @returns true if the data is a KTX file or false otherwise
  52592. */
  52593. static IsValid(data: ArrayBufferView): boolean;
  52594. }
  52595. }
  52596. declare module BABYLON {
  52597. /**
  52598. * Class for loading KTX2 files
  52599. * !!! Experimental Extension Subject to Changes !!!
  52600. * @hidden
  52601. */
  52602. export class KhronosTextureContainer2 {
  52603. private static _ModulePromise;
  52604. private static _TranscodeFormat;
  52605. constructor(engine: ThinEngine);
  52606. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52607. private _determineTranscodeFormat;
  52608. /**
  52609. * Checks if the given data starts with a KTX2 file identifier.
  52610. * @param data the data to check
  52611. * @returns true if the data is a KTX2 file or false otherwise
  52612. */
  52613. static IsValid(data: ArrayBufferView): boolean;
  52614. }
  52615. }
  52616. declare module BABYLON {
  52617. /**
  52618. * Implementation of the KTX Texture Loader.
  52619. * @hidden
  52620. */
  52621. export class _KTXTextureLoader implements IInternalTextureLoader {
  52622. /**
  52623. * Defines wether the loader supports cascade loading the different faces.
  52624. */
  52625. readonly supportCascades: boolean;
  52626. /**
  52627. * This returns if the loader support the current file information.
  52628. * @param extension defines the file extension of the file being loaded
  52629. * @returns true if the loader can load the specified file
  52630. */
  52631. canLoad(extension: string): boolean;
  52632. /**
  52633. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52634. * @param data contains the texture data
  52635. * @param texture defines the BabylonJS internal texture
  52636. * @param createPolynomials will be true if polynomials have been requested
  52637. * @param onLoad defines the callback to trigger once the texture is ready
  52638. * @param onError defines the callback to trigger in case of error
  52639. */
  52640. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52641. /**
  52642. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52643. * @param data contains the texture data
  52644. * @param texture defines the BabylonJS internal texture
  52645. * @param callback defines the method to call once ready to upload
  52646. */
  52647. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52648. }
  52649. }
  52650. declare module BABYLON {
  52651. /** @hidden */
  52652. export var _forceSceneHelpersToBundle: boolean;
  52653. interface Scene {
  52654. /**
  52655. * Creates a default light for the scene.
  52656. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52657. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52658. */
  52659. createDefaultLight(replace?: boolean): void;
  52660. /**
  52661. * Creates a default camera for the scene.
  52662. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52663. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52664. * @param replace has default false, when true replaces the active camera in the scene
  52665. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52666. */
  52667. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52668. /**
  52669. * Creates a default camera and a default light.
  52670. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52671. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52672. * @param replace has the default false, when true replaces the active camera/light in the scene
  52673. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52674. */
  52675. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52676. /**
  52677. * Creates a new sky box
  52678. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52679. * @param environmentTexture defines the texture to use as environment texture
  52680. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52681. * @param scale defines the overall scale of the skybox
  52682. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52683. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52684. * @returns a new mesh holding the sky box
  52685. */
  52686. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52687. /**
  52688. * Creates a new environment
  52689. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52690. * @param options defines the options you can use to configure the environment
  52691. * @returns the new EnvironmentHelper
  52692. */
  52693. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52694. /**
  52695. * Creates a new VREXperienceHelper
  52696. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52697. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52698. * @returns a new VREXperienceHelper
  52699. */
  52700. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52701. /**
  52702. * Creates a new WebXRDefaultExperience
  52703. * @see http://doc.babylonjs.com/how_to/webxr
  52704. * @param options experience options
  52705. * @returns a promise for a new WebXRDefaultExperience
  52706. */
  52707. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52708. }
  52709. }
  52710. declare module BABYLON {
  52711. /**
  52712. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52713. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52714. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52715. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52716. */
  52717. export class VideoDome extends TransformNode {
  52718. /**
  52719. * Define the video source as a Monoscopic panoramic 360 video.
  52720. */
  52721. static readonly MODE_MONOSCOPIC: number;
  52722. /**
  52723. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52724. */
  52725. static readonly MODE_TOPBOTTOM: number;
  52726. /**
  52727. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52728. */
  52729. static readonly MODE_SIDEBYSIDE: number;
  52730. private _halfDome;
  52731. private _useDirectMapping;
  52732. /**
  52733. * The video texture being displayed on the sphere
  52734. */
  52735. protected _videoTexture: VideoTexture;
  52736. /**
  52737. * Gets the video texture being displayed on the sphere
  52738. */
  52739. get videoTexture(): VideoTexture;
  52740. /**
  52741. * The skybox material
  52742. */
  52743. protected _material: BackgroundMaterial;
  52744. /**
  52745. * The surface used for the skybox
  52746. */
  52747. protected _mesh: Mesh;
  52748. /**
  52749. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52750. */
  52751. private _halfDomeMask;
  52752. /**
  52753. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52754. * Also see the options.resolution property.
  52755. */
  52756. get fovMultiplier(): number;
  52757. set fovMultiplier(value: number);
  52758. private _videoMode;
  52759. /**
  52760. * Gets or set the current video mode for the video. It can be:
  52761. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52762. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52763. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52764. */
  52765. get videoMode(): number;
  52766. set videoMode(value: number);
  52767. /**
  52768. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52769. *
  52770. */
  52771. get halfDome(): boolean;
  52772. /**
  52773. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52774. */
  52775. set halfDome(enabled: boolean);
  52776. /**
  52777. * Oberserver used in Stereoscopic VR Mode.
  52778. */
  52779. private _onBeforeCameraRenderObserver;
  52780. /**
  52781. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52782. * @param name Element's name, child elements will append suffixes for their own names.
  52783. * @param urlsOrVideo defines the url(s) or the video element to use
  52784. * @param options An object containing optional or exposed sub element properties
  52785. */
  52786. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52787. resolution?: number;
  52788. clickToPlay?: boolean;
  52789. autoPlay?: boolean;
  52790. loop?: boolean;
  52791. size?: number;
  52792. poster?: string;
  52793. faceForward?: boolean;
  52794. useDirectMapping?: boolean;
  52795. halfDomeMode?: boolean;
  52796. }, scene: Scene);
  52797. private _changeVideoMode;
  52798. /**
  52799. * Releases resources associated with this node.
  52800. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52801. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52802. */
  52803. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52804. }
  52805. }
  52806. declare module BABYLON {
  52807. /**
  52808. * This class can be used to get instrumentation data from a Babylon engine
  52809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52810. */
  52811. export class EngineInstrumentation implements IDisposable {
  52812. /**
  52813. * Define the instrumented engine.
  52814. */
  52815. engine: Engine;
  52816. private _captureGPUFrameTime;
  52817. private _gpuFrameTimeToken;
  52818. private _gpuFrameTime;
  52819. private _captureShaderCompilationTime;
  52820. private _shaderCompilationTime;
  52821. private _onBeginFrameObserver;
  52822. private _onEndFrameObserver;
  52823. private _onBeforeShaderCompilationObserver;
  52824. private _onAfterShaderCompilationObserver;
  52825. /**
  52826. * Gets the perf counter used for GPU frame time
  52827. */
  52828. get gpuFrameTimeCounter(): PerfCounter;
  52829. /**
  52830. * Gets the GPU frame time capture status
  52831. */
  52832. get captureGPUFrameTime(): boolean;
  52833. /**
  52834. * Enable or disable the GPU frame time capture
  52835. */
  52836. set captureGPUFrameTime(value: boolean);
  52837. /**
  52838. * Gets the perf counter used for shader compilation time
  52839. */
  52840. get shaderCompilationTimeCounter(): PerfCounter;
  52841. /**
  52842. * Gets the shader compilation time capture status
  52843. */
  52844. get captureShaderCompilationTime(): boolean;
  52845. /**
  52846. * Enable or disable the shader compilation time capture
  52847. */
  52848. set captureShaderCompilationTime(value: boolean);
  52849. /**
  52850. * Instantiates a new engine instrumentation.
  52851. * This class can be used to get instrumentation data from a Babylon engine
  52852. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52853. * @param engine Defines the engine to instrument
  52854. */
  52855. constructor(
  52856. /**
  52857. * Define the instrumented engine.
  52858. */
  52859. engine: Engine);
  52860. /**
  52861. * Dispose and release associated resources.
  52862. */
  52863. dispose(): void;
  52864. }
  52865. }
  52866. declare module BABYLON {
  52867. /**
  52868. * This class can be used to get instrumentation data from a Babylon engine
  52869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52870. */
  52871. export class SceneInstrumentation implements IDisposable {
  52872. /**
  52873. * Defines the scene to instrument
  52874. */
  52875. scene: Scene;
  52876. private _captureActiveMeshesEvaluationTime;
  52877. private _activeMeshesEvaluationTime;
  52878. private _captureRenderTargetsRenderTime;
  52879. private _renderTargetsRenderTime;
  52880. private _captureFrameTime;
  52881. private _frameTime;
  52882. private _captureRenderTime;
  52883. private _renderTime;
  52884. private _captureInterFrameTime;
  52885. private _interFrameTime;
  52886. private _captureParticlesRenderTime;
  52887. private _particlesRenderTime;
  52888. private _captureSpritesRenderTime;
  52889. private _spritesRenderTime;
  52890. private _capturePhysicsTime;
  52891. private _physicsTime;
  52892. private _captureAnimationsTime;
  52893. private _animationsTime;
  52894. private _captureCameraRenderTime;
  52895. private _cameraRenderTime;
  52896. private _onBeforeActiveMeshesEvaluationObserver;
  52897. private _onAfterActiveMeshesEvaluationObserver;
  52898. private _onBeforeRenderTargetsRenderObserver;
  52899. private _onAfterRenderTargetsRenderObserver;
  52900. private _onAfterRenderObserver;
  52901. private _onBeforeDrawPhaseObserver;
  52902. private _onAfterDrawPhaseObserver;
  52903. private _onBeforeAnimationsObserver;
  52904. private _onBeforeParticlesRenderingObserver;
  52905. private _onAfterParticlesRenderingObserver;
  52906. private _onBeforeSpritesRenderingObserver;
  52907. private _onAfterSpritesRenderingObserver;
  52908. private _onBeforePhysicsObserver;
  52909. private _onAfterPhysicsObserver;
  52910. private _onAfterAnimationsObserver;
  52911. private _onBeforeCameraRenderObserver;
  52912. private _onAfterCameraRenderObserver;
  52913. /**
  52914. * Gets the perf counter used for active meshes evaluation time
  52915. */
  52916. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52917. /**
  52918. * Gets the active meshes evaluation time capture status
  52919. */
  52920. get captureActiveMeshesEvaluationTime(): boolean;
  52921. /**
  52922. * Enable or disable the active meshes evaluation time capture
  52923. */
  52924. set captureActiveMeshesEvaluationTime(value: boolean);
  52925. /**
  52926. * Gets the perf counter used for render targets render time
  52927. */
  52928. get renderTargetsRenderTimeCounter(): PerfCounter;
  52929. /**
  52930. * Gets the render targets render time capture status
  52931. */
  52932. get captureRenderTargetsRenderTime(): boolean;
  52933. /**
  52934. * Enable or disable the render targets render time capture
  52935. */
  52936. set captureRenderTargetsRenderTime(value: boolean);
  52937. /**
  52938. * Gets the perf counter used for particles render time
  52939. */
  52940. get particlesRenderTimeCounter(): PerfCounter;
  52941. /**
  52942. * Gets the particles render time capture status
  52943. */
  52944. get captureParticlesRenderTime(): boolean;
  52945. /**
  52946. * Enable or disable the particles render time capture
  52947. */
  52948. set captureParticlesRenderTime(value: boolean);
  52949. /**
  52950. * Gets the perf counter used for sprites render time
  52951. */
  52952. get spritesRenderTimeCounter(): PerfCounter;
  52953. /**
  52954. * Gets the sprites render time capture status
  52955. */
  52956. get captureSpritesRenderTime(): boolean;
  52957. /**
  52958. * Enable or disable the sprites render time capture
  52959. */
  52960. set captureSpritesRenderTime(value: boolean);
  52961. /**
  52962. * Gets the perf counter used for physics time
  52963. */
  52964. get physicsTimeCounter(): PerfCounter;
  52965. /**
  52966. * Gets the physics time capture status
  52967. */
  52968. get capturePhysicsTime(): boolean;
  52969. /**
  52970. * Enable or disable the physics time capture
  52971. */
  52972. set capturePhysicsTime(value: boolean);
  52973. /**
  52974. * Gets the perf counter used for animations time
  52975. */
  52976. get animationsTimeCounter(): PerfCounter;
  52977. /**
  52978. * Gets the animations time capture status
  52979. */
  52980. get captureAnimationsTime(): boolean;
  52981. /**
  52982. * Enable or disable the animations time capture
  52983. */
  52984. set captureAnimationsTime(value: boolean);
  52985. /**
  52986. * Gets the perf counter used for frame time capture
  52987. */
  52988. get frameTimeCounter(): PerfCounter;
  52989. /**
  52990. * Gets the frame time capture status
  52991. */
  52992. get captureFrameTime(): boolean;
  52993. /**
  52994. * Enable or disable the frame time capture
  52995. */
  52996. set captureFrameTime(value: boolean);
  52997. /**
  52998. * Gets the perf counter used for inter-frames time capture
  52999. */
  53000. get interFrameTimeCounter(): PerfCounter;
  53001. /**
  53002. * Gets the inter-frames time capture status
  53003. */
  53004. get captureInterFrameTime(): boolean;
  53005. /**
  53006. * Enable or disable the inter-frames time capture
  53007. */
  53008. set captureInterFrameTime(value: boolean);
  53009. /**
  53010. * Gets the perf counter used for render time capture
  53011. */
  53012. get renderTimeCounter(): PerfCounter;
  53013. /**
  53014. * Gets the render time capture status
  53015. */
  53016. get captureRenderTime(): boolean;
  53017. /**
  53018. * Enable or disable the render time capture
  53019. */
  53020. set captureRenderTime(value: boolean);
  53021. /**
  53022. * Gets the perf counter used for camera render time capture
  53023. */
  53024. get cameraRenderTimeCounter(): PerfCounter;
  53025. /**
  53026. * Gets the camera render time capture status
  53027. */
  53028. get captureCameraRenderTime(): boolean;
  53029. /**
  53030. * Enable or disable the camera render time capture
  53031. */
  53032. set captureCameraRenderTime(value: boolean);
  53033. /**
  53034. * Gets the perf counter used for draw calls
  53035. */
  53036. get drawCallsCounter(): PerfCounter;
  53037. /**
  53038. * Instantiates a new scene instrumentation.
  53039. * This class can be used to get instrumentation data from a Babylon engine
  53040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53041. * @param scene Defines the scene to instrument
  53042. */
  53043. constructor(
  53044. /**
  53045. * Defines the scene to instrument
  53046. */
  53047. scene: Scene);
  53048. /**
  53049. * Dispose and release associated resources.
  53050. */
  53051. dispose(): void;
  53052. }
  53053. }
  53054. declare module BABYLON {
  53055. /** @hidden */
  53056. export var glowMapGenerationPixelShader: {
  53057. name: string;
  53058. shader: string;
  53059. };
  53060. }
  53061. declare module BABYLON {
  53062. /** @hidden */
  53063. export var glowMapGenerationVertexShader: {
  53064. name: string;
  53065. shader: string;
  53066. };
  53067. }
  53068. declare module BABYLON {
  53069. /**
  53070. * Effect layer options. This helps customizing the behaviour
  53071. * of the effect layer.
  53072. */
  53073. export interface IEffectLayerOptions {
  53074. /**
  53075. * Multiplication factor apply to the canvas size to compute the render target size
  53076. * used to generated the objects (the smaller the faster).
  53077. */
  53078. mainTextureRatio: number;
  53079. /**
  53080. * Enforces a fixed size texture to ensure effect stability across devices.
  53081. */
  53082. mainTextureFixedSize?: number;
  53083. /**
  53084. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53085. */
  53086. alphaBlendingMode: number;
  53087. /**
  53088. * The camera attached to the layer.
  53089. */
  53090. camera: Nullable<Camera>;
  53091. /**
  53092. * The rendering group to draw the layer in.
  53093. */
  53094. renderingGroupId: number;
  53095. }
  53096. /**
  53097. * The effect layer Helps adding post process effect blended with the main pass.
  53098. *
  53099. * This can be for instance use to generate glow or higlight effects on the scene.
  53100. *
  53101. * The effect layer class can not be used directly and is intented to inherited from to be
  53102. * customized per effects.
  53103. */
  53104. export abstract class EffectLayer {
  53105. private _vertexBuffers;
  53106. private _indexBuffer;
  53107. private _cachedDefines;
  53108. private _effectLayerMapGenerationEffect;
  53109. private _effectLayerOptions;
  53110. private _mergeEffect;
  53111. protected _scene: Scene;
  53112. protected _engine: Engine;
  53113. protected _maxSize: number;
  53114. protected _mainTextureDesiredSize: ISize;
  53115. protected _mainTexture: RenderTargetTexture;
  53116. protected _shouldRender: boolean;
  53117. protected _postProcesses: PostProcess[];
  53118. protected _textures: BaseTexture[];
  53119. protected _emissiveTextureAndColor: {
  53120. texture: Nullable<BaseTexture>;
  53121. color: Color4;
  53122. };
  53123. /**
  53124. * The name of the layer
  53125. */
  53126. name: string;
  53127. /**
  53128. * The clear color of the texture used to generate the glow map.
  53129. */
  53130. neutralColor: Color4;
  53131. /**
  53132. * Specifies whether the highlight layer is enabled or not.
  53133. */
  53134. isEnabled: boolean;
  53135. /**
  53136. * Gets the camera attached to the layer.
  53137. */
  53138. get camera(): Nullable<Camera>;
  53139. /**
  53140. * Gets the rendering group id the layer should render in.
  53141. */
  53142. get renderingGroupId(): number;
  53143. set renderingGroupId(renderingGroupId: number);
  53144. /**
  53145. * An event triggered when the effect layer has been disposed.
  53146. */
  53147. onDisposeObservable: Observable<EffectLayer>;
  53148. /**
  53149. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53150. */
  53151. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53152. /**
  53153. * An event triggered when the generated texture is being merged in the scene.
  53154. */
  53155. onBeforeComposeObservable: Observable<EffectLayer>;
  53156. /**
  53157. * An event triggered when the mesh is rendered into the effect render target.
  53158. */
  53159. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53160. /**
  53161. * An event triggered after the mesh has been rendered into the effect render target.
  53162. */
  53163. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53164. /**
  53165. * An event triggered when the generated texture has been merged in the scene.
  53166. */
  53167. onAfterComposeObservable: Observable<EffectLayer>;
  53168. /**
  53169. * An event triggered when the efffect layer changes its size.
  53170. */
  53171. onSizeChangedObservable: Observable<EffectLayer>;
  53172. /** @hidden */
  53173. static _SceneComponentInitialization: (scene: Scene) => void;
  53174. /**
  53175. * Instantiates a new effect Layer and references it in the scene.
  53176. * @param name The name of the layer
  53177. * @param scene The scene to use the layer in
  53178. */
  53179. constructor(
  53180. /** The Friendly of the effect in the scene */
  53181. name: string, scene: Scene);
  53182. /**
  53183. * Get the effect name of the layer.
  53184. * @return The effect name
  53185. */
  53186. abstract getEffectName(): string;
  53187. /**
  53188. * Checks for the readiness of the element composing the layer.
  53189. * @param subMesh the mesh to check for
  53190. * @param useInstances specify whether or not to use instances to render the mesh
  53191. * @return true if ready otherwise, false
  53192. */
  53193. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53194. /**
  53195. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53196. * @returns true if the effect requires stencil during the main canvas render pass.
  53197. */
  53198. abstract needStencil(): boolean;
  53199. /**
  53200. * Create the merge effect. This is the shader use to blit the information back
  53201. * to the main canvas at the end of the scene rendering.
  53202. * @returns The effect containing the shader used to merge the effect on the main canvas
  53203. */
  53204. protected abstract _createMergeEffect(): Effect;
  53205. /**
  53206. * Creates the render target textures and post processes used in the effect layer.
  53207. */
  53208. protected abstract _createTextureAndPostProcesses(): void;
  53209. /**
  53210. * Implementation specific of rendering the generating effect on the main canvas.
  53211. * @param effect The effect used to render through
  53212. */
  53213. protected abstract _internalRender(effect: Effect): void;
  53214. /**
  53215. * Sets the required values for both the emissive texture and and the main color.
  53216. */
  53217. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53218. /**
  53219. * Free any resources and references associated to a mesh.
  53220. * Internal use
  53221. * @param mesh The mesh to free.
  53222. */
  53223. abstract _disposeMesh(mesh: Mesh): void;
  53224. /**
  53225. * Serializes this layer (Glow or Highlight for example)
  53226. * @returns a serialized layer object
  53227. */
  53228. abstract serialize?(): any;
  53229. /**
  53230. * Initializes the effect layer with the required options.
  53231. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53232. */
  53233. protected _init(options: Partial<IEffectLayerOptions>): void;
  53234. /**
  53235. * Generates the index buffer of the full screen quad blending to the main canvas.
  53236. */
  53237. private _generateIndexBuffer;
  53238. /**
  53239. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53240. */
  53241. private _generateVertexBuffer;
  53242. /**
  53243. * Sets the main texture desired size which is the closest power of two
  53244. * of the engine canvas size.
  53245. */
  53246. private _setMainTextureSize;
  53247. /**
  53248. * Creates the main texture for the effect layer.
  53249. */
  53250. protected _createMainTexture(): void;
  53251. /**
  53252. * Adds specific effects defines.
  53253. * @param defines The defines to add specifics to.
  53254. */
  53255. protected _addCustomEffectDefines(defines: string[]): void;
  53256. /**
  53257. * Checks for the readiness of the element composing the layer.
  53258. * @param subMesh the mesh to check for
  53259. * @param useInstances specify whether or not to use instances to render the mesh
  53260. * @param emissiveTexture the associated emissive texture used to generate the glow
  53261. * @return true if ready otherwise, false
  53262. */
  53263. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53264. /**
  53265. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53266. */
  53267. render(): void;
  53268. /**
  53269. * Determine if a given mesh will be used in the current effect.
  53270. * @param mesh mesh to test
  53271. * @returns true if the mesh will be used
  53272. */
  53273. hasMesh(mesh: AbstractMesh): boolean;
  53274. /**
  53275. * Returns true if the layer contains information to display, otherwise false.
  53276. * @returns true if the glow layer should be rendered
  53277. */
  53278. shouldRender(): boolean;
  53279. /**
  53280. * Returns true if the mesh should render, otherwise false.
  53281. * @param mesh The mesh to render
  53282. * @returns true if it should render otherwise false
  53283. */
  53284. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53285. /**
  53286. * Returns true if the mesh can be rendered, otherwise false.
  53287. * @param mesh The mesh to render
  53288. * @param material The material used on the mesh
  53289. * @returns true if it can be rendered otherwise false
  53290. */
  53291. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53292. /**
  53293. * Returns true if the mesh should render, otherwise false.
  53294. * @param mesh The mesh to render
  53295. * @returns true if it should render otherwise false
  53296. */
  53297. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53298. /**
  53299. * Renders the submesh passed in parameter to the generation map.
  53300. */
  53301. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53302. /**
  53303. * Defines whether the current material of the mesh should be use to render the effect.
  53304. * @param mesh defines the current mesh to render
  53305. */
  53306. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53307. /**
  53308. * Rebuild the required buffers.
  53309. * @hidden Internal use only.
  53310. */
  53311. _rebuild(): void;
  53312. /**
  53313. * Dispose only the render target textures and post process.
  53314. */
  53315. private _disposeTextureAndPostProcesses;
  53316. /**
  53317. * Dispose the highlight layer and free resources.
  53318. */
  53319. dispose(): void;
  53320. /**
  53321. * Gets the class name of the effect layer
  53322. * @returns the string with the class name of the effect layer
  53323. */
  53324. getClassName(): string;
  53325. /**
  53326. * Creates an effect layer from parsed effect layer data
  53327. * @param parsedEffectLayer defines effect layer data
  53328. * @param scene defines the current scene
  53329. * @param rootUrl defines the root URL containing the effect layer information
  53330. * @returns a parsed effect Layer
  53331. */
  53332. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53333. }
  53334. }
  53335. declare module BABYLON {
  53336. interface AbstractScene {
  53337. /**
  53338. * The list of effect layers (highlights/glow) added to the scene
  53339. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53340. * @see http://doc.babylonjs.com/how_to/glow_layer
  53341. */
  53342. effectLayers: Array<EffectLayer>;
  53343. /**
  53344. * Removes the given effect layer from this scene.
  53345. * @param toRemove defines the effect layer to remove
  53346. * @returns the index of the removed effect layer
  53347. */
  53348. removeEffectLayer(toRemove: EffectLayer): number;
  53349. /**
  53350. * Adds the given effect layer to this scene
  53351. * @param newEffectLayer defines the effect layer to add
  53352. */
  53353. addEffectLayer(newEffectLayer: EffectLayer): void;
  53354. }
  53355. /**
  53356. * Defines the layer scene component responsible to manage any effect layers
  53357. * in a given scene.
  53358. */
  53359. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53360. /**
  53361. * The component name helpfull to identify the component in the list of scene components.
  53362. */
  53363. readonly name: string;
  53364. /**
  53365. * The scene the component belongs to.
  53366. */
  53367. scene: Scene;
  53368. private _engine;
  53369. private _renderEffects;
  53370. private _needStencil;
  53371. private _previousStencilState;
  53372. /**
  53373. * Creates a new instance of the component for the given scene
  53374. * @param scene Defines the scene to register the component in
  53375. */
  53376. constructor(scene: Scene);
  53377. /**
  53378. * Registers the component in a given scene
  53379. */
  53380. register(): void;
  53381. /**
  53382. * Rebuilds the elements related to this component in case of
  53383. * context lost for instance.
  53384. */
  53385. rebuild(): void;
  53386. /**
  53387. * Serializes the component data to the specified json object
  53388. * @param serializationObject The object to serialize to
  53389. */
  53390. serialize(serializationObject: any): void;
  53391. /**
  53392. * Adds all the elements from the container to the scene
  53393. * @param container the container holding the elements
  53394. */
  53395. addFromContainer(container: AbstractScene): void;
  53396. /**
  53397. * Removes all the elements in the container from the scene
  53398. * @param container contains the elements to remove
  53399. * @param dispose if the removed element should be disposed (default: false)
  53400. */
  53401. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53402. /**
  53403. * Disposes the component and the associated ressources.
  53404. */
  53405. dispose(): void;
  53406. private _isReadyForMesh;
  53407. private _renderMainTexture;
  53408. private _setStencil;
  53409. private _setStencilBack;
  53410. private _draw;
  53411. private _drawCamera;
  53412. private _drawRenderingGroup;
  53413. }
  53414. }
  53415. declare module BABYLON {
  53416. /** @hidden */
  53417. export var glowMapMergePixelShader: {
  53418. name: string;
  53419. shader: string;
  53420. };
  53421. }
  53422. declare module BABYLON {
  53423. /** @hidden */
  53424. export var glowMapMergeVertexShader: {
  53425. name: string;
  53426. shader: string;
  53427. };
  53428. }
  53429. declare module BABYLON {
  53430. interface AbstractScene {
  53431. /**
  53432. * Return a the first highlight layer of the scene with a given name.
  53433. * @param name The name of the highlight layer to look for.
  53434. * @return The highlight layer if found otherwise null.
  53435. */
  53436. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53437. }
  53438. /**
  53439. * Glow layer options. This helps customizing the behaviour
  53440. * of the glow layer.
  53441. */
  53442. export interface IGlowLayerOptions {
  53443. /**
  53444. * Multiplication factor apply to the canvas size to compute the render target size
  53445. * used to generated the glowing objects (the smaller the faster).
  53446. */
  53447. mainTextureRatio: number;
  53448. /**
  53449. * Enforces a fixed size texture to ensure resize independant blur.
  53450. */
  53451. mainTextureFixedSize?: number;
  53452. /**
  53453. * How big is the kernel of the blur texture.
  53454. */
  53455. blurKernelSize: number;
  53456. /**
  53457. * The camera attached to the layer.
  53458. */
  53459. camera: Nullable<Camera>;
  53460. /**
  53461. * Enable MSAA by chosing the number of samples.
  53462. */
  53463. mainTextureSamples?: number;
  53464. /**
  53465. * The rendering group to draw the layer in.
  53466. */
  53467. renderingGroupId: number;
  53468. }
  53469. /**
  53470. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53471. *
  53472. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53473. *
  53474. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53475. */
  53476. export class GlowLayer extends EffectLayer {
  53477. /**
  53478. * Effect Name of the layer.
  53479. */
  53480. static readonly EffectName: string;
  53481. /**
  53482. * The default blur kernel size used for the glow.
  53483. */
  53484. static DefaultBlurKernelSize: number;
  53485. /**
  53486. * The default texture size ratio used for the glow.
  53487. */
  53488. static DefaultTextureRatio: number;
  53489. /**
  53490. * Sets the kernel size of the blur.
  53491. */
  53492. set blurKernelSize(value: number);
  53493. /**
  53494. * Gets the kernel size of the blur.
  53495. */
  53496. get blurKernelSize(): number;
  53497. /**
  53498. * Sets the glow intensity.
  53499. */
  53500. set intensity(value: number);
  53501. /**
  53502. * Gets the glow intensity.
  53503. */
  53504. get intensity(): number;
  53505. private _options;
  53506. private _intensity;
  53507. private _horizontalBlurPostprocess1;
  53508. private _verticalBlurPostprocess1;
  53509. private _horizontalBlurPostprocess2;
  53510. private _verticalBlurPostprocess2;
  53511. private _blurTexture1;
  53512. private _blurTexture2;
  53513. private _postProcesses1;
  53514. private _postProcesses2;
  53515. private _includedOnlyMeshes;
  53516. private _excludedMeshes;
  53517. private _meshesUsingTheirOwnMaterials;
  53518. /**
  53519. * Callback used to let the user override the color selection on a per mesh basis
  53520. */
  53521. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53522. /**
  53523. * Callback used to let the user override the texture selection on a per mesh basis
  53524. */
  53525. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53526. /**
  53527. * Instantiates a new glow Layer and references it to the scene.
  53528. * @param name The name of the layer
  53529. * @param scene The scene to use the layer in
  53530. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53531. */
  53532. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53533. /**
  53534. * Get the effect name of the layer.
  53535. * @return The effect name
  53536. */
  53537. getEffectName(): string;
  53538. /**
  53539. * Create the merge effect. This is the shader use to blit the information back
  53540. * to the main canvas at the end of the scene rendering.
  53541. */
  53542. protected _createMergeEffect(): Effect;
  53543. /**
  53544. * Creates the render target textures and post processes used in the glow layer.
  53545. */
  53546. protected _createTextureAndPostProcesses(): void;
  53547. /**
  53548. * Checks for the readiness of the element composing the layer.
  53549. * @param subMesh the mesh to check for
  53550. * @param useInstances specify wether or not to use instances to render the mesh
  53551. * @param emissiveTexture the associated emissive texture used to generate the glow
  53552. * @return true if ready otherwise, false
  53553. */
  53554. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53555. /**
  53556. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53557. */
  53558. needStencil(): boolean;
  53559. /**
  53560. * Returns true if the mesh can be rendered, otherwise false.
  53561. * @param mesh The mesh to render
  53562. * @param material The material used on the mesh
  53563. * @returns true if it can be rendered otherwise false
  53564. */
  53565. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53566. /**
  53567. * Implementation specific of rendering the generating effect on the main canvas.
  53568. * @param effect The effect used to render through
  53569. */
  53570. protected _internalRender(effect: Effect): void;
  53571. /**
  53572. * Sets the required values for both the emissive texture and and the main color.
  53573. */
  53574. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53575. /**
  53576. * Returns true if the mesh should render, otherwise false.
  53577. * @param mesh The mesh to render
  53578. * @returns true if it should render otherwise false
  53579. */
  53580. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53581. /**
  53582. * Adds specific effects defines.
  53583. * @param defines The defines to add specifics to.
  53584. */
  53585. protected _addCustomEffectDefines(defines: string[]): void;
  53586. /**
  53587. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53588. * @param mesh The mesh to exclude from the glow layer
  53589. */
  53590. addExcludedMesh(mesh: Mesh): void;
  53591. /**
  53592. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53593. * @param mesh The mesh to remove
  53594. */
  53595. removeExcludedMesh(mesh: Mesh): void;
  53596. /**
  53597. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53598. * @param mesh The mesh to include in the glow layer
  53599. */
  53600. addIncludedOnlyMesh(mesh: Mesh): void;
  53601. /**
  53602. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53603. * @param mesh The mesh to remove
  53604. */
  53605. removeIncludedOnlyMesh(mesh: Mesh): void;
  53606. /**
  53607. * Determine if a given mesh will be used in the glow layer
  53608. * @param mesh The mesh to test
  53609. * @returns true if the mesh will be highlighted by the current glow layer
  53610. */
  53611. hasMesh(mesh: AbstractMesh): boolean;
  53612. /**
  53613. * Defines whether the current material of the mesh should be use to render the effect.
  53614. * @param mesh defines the current mesh to render
  53615. */
  53616. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53617. /**
  53618. * Add a mesh to be rendered through its own material and not with emissive only.
  53619. * @param mesh The mesh for which we need to use its material
  53620. */
  53621. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53622. /**
  53623. * Remove a mesh from being rendered through its own material and not with emissive only.
  53624. * @param mesh The mesh for which we need to not use its material
  53625. */
  53626. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53627. /**
  53628. * Free any resources and references associated to a mesh.
  53629. * Internal use
  53630. * @param mesh The mesh to free.
  53631. * @hidden
  53632. */
  53633. _disposeMesh(mesh: Mesh): void;
  53634. /**
  53635. * Gets the class name of the effect layer
  53636. * @returns the string with the class name of the effect layer
  53637. */
  53638. getClassName(): string;
  53639. /**
  53640. * Serializes this glow layer
  53641. * @returns a serialized glow layer object
  53642. */
  53643. serialize(): any;
  53644. /**
  53645. * Creates a Glow Layer from parsed glow layer data
  53646. * @param parsedGlowLayer defines glow layer data
  53647. * @param scene defines the current scene
  53648. * @param rootUrl defines the root URL containing the glow layer information
  53649. * @returns a parsed Glow Layer
  53650. */
  53651. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53652. }
  53653. }
  53654. declare module BABYLON {
  53655. /** @hidden */
  53656. export var glowBlurPostProcessPixelShader: {
  53657. name: string;
  53658. shader: string;
  53659. };
  53660. }
  53661. declare module BABYLON {
  53662. interface AbstractScene {
  53663. /**
  53664. * Return a the first highlight layer of the scene with a given name.
  53665. * @param name The name of the highlight layer to look for.
  53666. * @return The highlight layer if found otherwise null.
  53667. */
  53668. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53669. }
  53670. /**
  53671. * Highlight layer options. This helps customizing the behaviour
  53672. * of the highlight layer.
  53673. */
  53674. export interface IHighlightLayerOptions {
  53675. /**
  53676. * Multiplication factor apply to the canvas size to compute the render target size
  53677. * used to generated the glowing objects (the smaller the faster).
  53678. */
  53679. mainTextureRatio: number;
  53680. /**
  53681. * Enforces a fixed size texture to ensure resize independant blur.
  53682. */
  53683. mainTextureFixedSize?: number;
  53684. /**
  53685. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53686. * of the picture to blur (the smaller the faster).
  53687. */
  53688. blurTextureSizeRatio: number;
  53689. /**
  53690. * How big in texel of the blur texture is the vertical blur.
  53691. */
  53692. blurVerticalSize: number;
  53693. /**
  53694. * How big in texel of the blur texture is the horizontal blur.
  53695. */
  53696. blurHorizontalSize: number;
  53697. /**
  53698. * Alpha blending mode used to apply the blur. Default is combine.
  53699. */
  53700. alphaBlendingMode: number;
  53701. /**
  53702. * The camera attached to the layer.
  53703. */
  53704. camera: Nullable<Camera>;
  53705. /**
  53706. * Should we display highlight as a solid stroke?
  53707. */
  53708. isStroke?: boolean;
  53709. /**
  53710. * The rendering group to draw the layer in.
  53711. */
  53712. renderingGroupId: number;
  53713. }
  53714. /**
  53715. * The highlight layer Helps adding a glow effect around a mesh.
  53716. *
  53717. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53718. * glowy meshes to your scene.
  53719. *
  53720. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53721. */
  53722. export class HighlightLayer extends EffectLayer {
  53723. name: string;
  53724. /**
  53725. * Effect Name of the highlight layer.
  53726. */
  53727. static readonly EffectName: string;
  53728. /**
  53729. * The neutral color used during the preparation of the glow effect.
  53730. * This is black by default as the blend operation is a blend operation.
  53731. */
  53732. static NeutralColor: Color4;
  53733. /**
  53734. * Stencil value used for glowing meshes.
  53735. */
  53736. static GlowingMeshStencilReference: number;
  53737. /**
  53738. * Stencil value used for the other meshes in the scene.
  53739. */
  53740. static NormalMeshStencilReference: number;
  53741. /**
  53742. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53743. */
  53744. innerGlow: boolean;
  53745. /**
  53746. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53747. */
  53748. outerGlow: boolean;
  53749. /**
  53750. * Specifies the horizontal size of the blur.
  53751. */
  53752. set blurHorizontalSize(value: number);
  53753. /**
  53754. * Specifies the vertical size of the blur.
  53755. */
  53756. set blurVerticalSize(value: number);
  53757. /**
  53758. * Gets the horizontal size of the blur.
  53759. */
  53760. get blurHorizontalSize(): number;
  53761. /**
  53762. * Gets the vertical size of the blur.
  53763. */
  53764. get blurVerticalSize(): number;
  53765. /**
  53766. * An event triggered when the highlight layer is being blurred.
  53767. */
  53768. onBeforeBlurObservable: Observable<HighlightLayer>;
  53769. /**
  53770. * An event triggered when the highlight layer has been blurred.
  53771. */
  53772. onAfterBlurObservable: Observable<HighlightLayer>;
  53773. private _instanceGlowingMeshStencilReference;
  53774. private _options;
  53775. private _downSamplePostprocess;
  53776. private _horizontalBlurPostprocess;
  53777. private _verticalBlurPostprocess;
  53778. private _blurTexture;
  53779. private _meshes;
  53780. private _excludedMeshes;
  53781. /**
  53782. * Instantiates a new highlight Layer and references it to the scene..
  53783. * @param name The name of the layer
  53784. * @param scene The scene to use the layer in
  53785. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53786. */
  53787. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53788. /**
  53789. * Get the effect name of the layer.
  53790. * @return The effect name
  53791. */
  53792. getEffectName(): string;
  53793. /**
  53794. * Create the merge effect. This is the shader use to blit the information back
  53795. * to the main canvas at the end of the scene rendering.
  53796. */
  53797. protected _createMergeEffect(): Effect;
  53798. /**
  53799. * Creates the render target textures and post processes used in the highlight layer.
  53800. */
  53801. protected _createTextureAndPostProcesses(): void;
  53802. /**
  53803. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53804. */
  53805. needStencil(): boolean;
  53806. /**
  53807. * Checks for the readiness of the element composing the layer.
  53808. * @param subMesh the mesh to check for
  53809. * @param useInstances specify wether or not to use instances to render the mesh
  53810. * @param emissiveTexture the associated emissive texture used to generate the glow
  53811. * @return true if ready otherwise, false
  53812. */
  53813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53814. /**
  53815. * Implementation specific of rendering the generating effect on the main canvas.
  53816. * @param effect The effect used to render through
  53817. */
  53818. protected _internalRender(effect: Effect): void;
  53819. /**
  53820. * Returns true if the layer contains information to display, otherwise false.
  53821. */
  53822. shouldRender(): boolean;
  53823. /**
  53824. * Returns true if the mesh should render, otherwise false.
  53825. * @param mesh The mesh to render
  53826. * @returns true if it should render otherwise false
  53827. */
  53828. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53829. /**
  53830. * Sets the required values for both the emissive texture and and the main color.
  53831. */
  53832. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53833. /**
  53834. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53835. * @param mesh The mesh to exclude from the highlight layer
  53836. */
  53837. addExcludedMesh(mesh: Mesh): void;
  53838. /**
  53839. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53840. * @param mesh The mesh to highlight
  53841. */
  53842. removeExcludedMesh(mesh: Mesh): void;
  53843. /**
  53844. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53845. * @param mesh mesh to test
  53846. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53847. */
  53848. hasMesh(mesh: AbstractMesh): boolean;
  53849. /**
  53850. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53851. * @param mesh The mesh to highlight
  53852. * @param color The color of the highlight
  53853. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53854. */
  53855. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53856. /**
  53857. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53858. * @param mesh The mesh to highlight
  53859. */
  53860. removeMesh(mesh: Mesh): void;
  53861. /**
  53862. * Remove all the meshes currently referenced in the highlight layer
  53863. */
  53864. removeAllMeshes(): void;
  53865. /**
  53866. * Force the stencil to the normal expected value for none glowing parts
  53867. */
  53868. private _defaultStencilReference;
  53869. /**
  53870. * Free any resources and references associated to a mesh.
  53871. * Internal use
  53872. * @param mesh The mesh to free.
  53873. * @hidden
  53874. */
  53875. _disposeMesh(mesh: Mesh): void;
  53876. /**
  53877. * Dispose the highlight layer and free resources.
  53878. */
  53879. dispose(): void;
  53880. /**
  53881. * Gets the class name of the effect layer
  53882. * @returns the string with the class name of the effect layer
  53883. */
  53884. getClassName(): string;
  53885. /**
  53886. * Serializes this Highlight layer
  53887. * @returns a serialized Highlight layer object
  53888. */
  53889. serialize(): any;
  53890. /**
  53891. * Creates a Highlight layer from parsed Highlight layer data
  53892. * @param parsedHightlightLayer defines the Highlight layer data
  53893. * @param scene defines the current scene
  53894. * @param rootUrl defines the root URL containing the Highlight layer information
  53895. * @returns a parsed Highlight layer
  53896. */
  53897. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53898. }
  53899. }
  53900. declare module BABYLON {
  53901. interface AbstractScene {
  53902. /**
  53903. * The list of layers (background and foreground) of the scene
  53904. */
  53905. layers: Array<Layer>;
  53906. }
  53907. /**
  53908. * Defines the layer scene component responsible to manage any layers
  53909. * in a given scene.
  53910. */
  53911. export class LayerSceneComponent implements ISceneComponent {
  53912. /**
  53913. * The component name helpfull to identify the component in the list of scene components.
  53914. */
  53915. readonly name: string;
  53916. /**
  53917. * The scene the component belongs to.
  53918. */
  53919. scene: Scene;
  53920. private _engine;
  53921. /**
  53922. * Creates a new instance of the component for the given scene
  53923. * @param scene Defines the scene to register the component in
  53924. */
  53925. constructor(scene: Scene);
  53926. /**
  53927. * Registers the component in a given scene
  53928. */
  53929. register(): void;
  53930. /**
  53931. * Rebuilds the elements related to this component in case of
  53932. * context lost for instance.
  53933. */
  53934. rebuild(): void;
  53935. /**
  53936. * Disposes the component and the associated ressources.
  53937. */
  53938. dispose(): void;
  53939. private _draw;
  53940. private _drawCameraPredicate;
  53941. private _drawCameraBackground;
  53942. private _drawCameraForeground;
  53943. private _drawRenderTargetPredicate;
  53944. private _drawRenderTargetBackground;
  53945. private _drawRenderTargetForeground;
  53946. /**
  53947. * Adds all the elements from the container to the scene
  53948. * @param container the container holding the elements
  53949. */
  53950. addFromContainer(container: AbstractScene): void;
  53951. /**
  53952. * Removes all the elements in the container from the scene
  53953. * @param container contains the elements to remove
  53954. * @param dispose if the removed element should be disposed (default: false)
  53955. */
  53956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53957. }
  53958. }
  53959. declare module BABYLON {
  53960. /** @hidden */
  53961. export var layerPixelShader: {
  53962. name: string;
  53963. shader: string;
  53964. };
  53965. }
  53966. declare module BABYLON {
  53967. /** @hidden */
  53968. export var layerVertexShader: {
  53969. name: string;
  53970. shader: string;
  53971. };
  53972. }
  53973. declare module BABYLON {
  53974. /**
  53975. * This represents a full screen 2d layer.
  53976. * This can be useful to display a picture in the background of your scene for instance.
  53977. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53978. */
  53979. export class Layer {
  53980. /**
  53981. * Define the name of the layer.
  53982. */
  53983. name: string;
  53984. /**
  53985. * Define the texture the layer should display.
  53986. */
  53987. texture: Nullable<Texture>;
  53988. /**
  53989. * Is the layer in background or foreground.
  53990. */
  53991. isBackground: boolean;
  53992. /**
  53993. * Define the color of the layer (instead of texture).
  53994. */
  53995. color: Color4;
  53996. /**
  53997. * Define the scale of the layer in order to zoom in out of the texture.
  53998. */
  53999. scale: Vector2;
  54000. /**
  54001. * Define an offset for the layer in order to shift the texture.
  54002. */
  54003. offset: Vector2;
  54004. /**
  54005. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54006. */
  54007. alphaBlendingMode: number;
  54008. /**
  54009. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54010. * Alpha test will not mix with the background color in case of transparency.
  54011. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54012. */
  54013. alphaTest: boolean;
  54014. /**
  54015. * Define a mask to restrict the layer to only some of the scene cameras.
  54016. */
  54017. layerMask: number;
  54018. /**
  54019. * Define the list of render target the layer is visible into.
  54020. */
  54021. renderTargetTextures: RenderTargetTexture[];
  54022. /**
  54023. * Define if the layer is only used in renderTarget or if it also
  54024. * renders in the main frame buffer of the canvas.
  54025. */
  54026. renderOnlyInRenderTargetTextures: boolean;
  54027. private _scene;
  54028. private _vertexBuffers;
  54029. private _indexBuffer;
  54030. private _effect;
  54031. private _previousDefines;
  54032. /**
  54033. * An event triggered when the layer is disposed.
  54034. */
  54035. onDisposeObservable: Observable<Layer>;
  54036. private _onDisposeObserver;
  54037. /**
  54038. * Back compatibility with callback before the onDisposeObservable existed.
  54039. * The set callback will be triggered when the layer has been disposed.
  54040. */
  54041. set onDispose(callback: () => void);
  54042. /**
  54043. * An event triggered before rendering the scene
  54044. */
  54045. onBeforeRenderObservable: Observable<Layer>;
  54046. private _onBeforeRenderObserver;
  54047. /**
  54048. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54049. * The set callback will be triggered just before rendering the layer.
  54050. */
  54051. set onBeforeRender(callback: () => void);
  54052. /**
  54053. * An event triggered after rendering the scene
  54054. */
  54055. onAfterRenderObservable: Observable<Layer>;
  54056. private _onAfterRenderObserver;
  54057. /**
  54058. * Back compatibility with callback before the onAfterRenderObservable existed.
  54059. * The set callback will be triggered just after rendering the layer.
  54060. */
  54061. set onAfterRender(callback: () => void);
  54062. /**
  54063. * Instantiates a new layer.
  54064. * This represents a full screen 2d layer.
  54065. * This can be useful to display a picture in the background of your scene for instance.
  54066. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54067. * @param name Define the name of the layer in the scene
  54068. * @param imgUrl Define the url of the texture to display in the layer
  54069. * @param scene Define the scene the layer belongs to
  54070. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54071. * @param color Defines a color for the layer
  54072. */
  54073. constructor(
  54074. /**
  54075. * Define the name of the layer.
  54076. */
  54077. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54078. private _createIndexBuffer;
  54079. /** @hidden */
  54080. _rebuild(): void;
  54081. /**
  54082. * Renders the layer in the scene.
  54083. */
  54084. render(): void;
  54085. /**
  54086. * Disposes and releases the associated ressources.
  54087. */
  54088. dispose(): void;
  54089. }
  54090. }
  54091. declare module BABYLON {
  54092. /** @hidden */
  54093. export var lensFlarePixelShader: {
  54094. name: string;
  54095. shader: string;
  54096. };
  54097. }
  54098. declare module BABYLON {
  54099. /** @hidden */
  54100. export var lensFlareVertexShader: {
  54101. name: string;
  54102. shader: string;
  54103. };
  54104. }
  54105. declare module BABYLON {
  54106. /**
  54107. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54108. * It is usually composed of several `lensFlare`.
  54109. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54110. */
  54111. export class LensFlareSystem {
  54112. /**
  54113. * Define the name of the lens flare system
  54114. */
  54115. name: string;
  54116. /**
  54117. * List of lens flares used in this system.
  54118. */
  54119. lensFlares: LensFlare[];
  54120. /**
  54121. * Define a limit from the border the lens flare can be visible.
  54122. */
  54123. borderLimit: number;
  54124. /**
  54125. * Define a viewport border we do not want to see the lens flare in.
  54126. */
  54127. viewportBorder: number;
  54128. /**
  54129. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54130. */
  54131. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54132. /**
  54133. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54134. */
  54135. layerMask: number;
  54136. /**
  54137. * Define the id of the lens flare system in the scene.
  54138. * (equal to name by default)
  54139. */
  54140. id: string;
  54141. private _scene;
  54142. private _emitter;
  54143. private _vertexBuffers;
  54144. private _indexBuffer;
  54145. private _effect;
  54146. private _positionX;
  54147. private _positionY;
  54148. private _isEnabled;
  54149. /** @hidden */
  54150. static _SceneComponentInitialization: (scene: Scene) => void;
  54151. /**
  54152. * Instantiates a lens flare system.
  54153. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54154. * It is usually composed of several `lensFlare`.
  54155. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54156. * @param name Define the name of the lens flare system in the scene
  54157. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54158. * @param scene Define the scene the lens flare system belongs to
  54159. */
  54160. constructor(
  54161. /**
  54162. * Define the name of the lens flare system
  54163. */
  54164. name: string, emitter: any, scene: Scene);
  54165. /**
  54166. * Define if the lens flare system is enabled.
  54167. */
  54168. get isEnabled(): boolean;
  54169. set isEnabled(value: boolean);
  54170. /**
  54171. * Get the scene the effects belongs to.
  54172. * @returns the scene holding the lens flare system
  54173. */
  54174. getScene(): Scene;
  54175. /**
  54176. * Get the emitter of the lens flare system.
  54177. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54178. * @returns the emitter of the lens flare system
  54179. */
  54180. getEmitter(): any;
  54181. /**
  54182. * Set the emitter of the lens flare system.
  54183. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54184. * @param newEmitter Define the new emitter of the system
  54185. */
  54186. setEmitter(newEmitter: any): void;
  54187. /**
  54188. * Get the lens flare system emitter position.
  54189. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54190. * @returns the position
  54191. */
  54192. getEmitterPosition(): Vector3;
  54193. /**
  54194. * @hidden
  54195. */
  54196. computeEffectivePosition(globalViewport: Viewport): boolean;
  54197. /** @hidden */
  54198. _isVisible(): boolean;
  54199. /**
  54200. * @hidden
  54201. */
  54202. render(): boolean;
  54203. /**
  54204. * Dispose and release the lens flare with its associated resources.
  54205. */
  54206. dispose(): void;
  54207. /**
  54208. * Parse a lens flare system from a JSON repressentation
  54209. * @param parsedLensFlareSystem Define the JSON to parse
  54210. * @param scene Define the scene the parsed system should be instantiated in
  54211. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54212. * @returns the parsed system
  54213. */
  54214. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54215. /**
  54216. * Serialize the current Lens Flare System into a JSON representation.
  54217. * @returns the serialized JSON
  54218. */
  54219. serialize(): any;
  54220. }
  54221. }
  54222. declare module BABYLON {
  54223. /**
  54224. * This represents one of the lens effect in a `lensFlareSystem`.
  54225. * It controls one of the indiviual texture used in the effect.
  54226. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54227. */
  54228. export class LensFlare {
  54229. /**
  54230. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54231. */
  54232. size: number;
  54233. /**
  54234. * 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.
  54235. */
  54236. position: number;
  54237. /**
  54238. * Define the lens color.
  54239. */
  54240. color: Color3;
  54241. /**
  54242. * Define the lens texture.
  54243. */
  54244. texture: Nullable<Texture>;
  54245. /**
  54246. * Define the alpha mode to render this particular lens.
  54247. */
  54248. alphaMode: number;
  54249. private _system;
  54250. /**
  54251. * Creates a new Lens Flare.
  54252. * This represents one of the lens effect in a `lensFlareSystem`.
  54253. * It controls one of the indiviual texture used in the effect.
  54254. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54255. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54256. * @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.
  54257. * @param color Define the lens color
  54258. * @param imgUrl Define the lens texture url
  54259. * @param system Define the `lensFlareSystem` this flare is part of
  54260. * @returns The newly created Lens Flare
  54261. */
  54262. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54263. /**
  54264. * Instantiates a new Lens Flare.
  54265. * This represents one of the lens effect in a `lensFlareSystem`.
  54266. * It controls one of the indiviual texture used in the effect.
  54267. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54268. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54269. * @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.
  54270. * @param color Define the lens color
  54271. * @param imgUrl Define the lens texture url
  54272. * @param system Define the `lensFlareSystem` this flare is part of
  54273. */
  54274. constructor(
  54275. /**
  54276. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54277. */
  54278. size: number,
  54279. /**
  54280. * 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.
  54281. */
  54282. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54283. /**
  54284. * Dispose and release the lens flare with its associated resources.
  54285. */
  54286. dispose(): void;
  54287. }
  54288. }
  54289. declare module BABYLON {
  54290. interface AbstractScene {
  54291. /**
  54292. * The list of lens flare system added to the scene
  54293. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54294. */
  54295. lensFlareSystems: Array<LensFlareSystem>;
  54296. /**
  54297. * Removes the given lens flare system from this scene.
  54298. * @param toRemove The lens flare system to remove
  54299. * @returns The index of the removed lens flare system
  54300. */
  54301. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54302. /**
  54303. * Adds the given lens flare system to this scene
  54304. * @param newLensFlareSystem The lens flare system to add
  54305. */
  54306. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54307. /**
  54308. * Gets a lens flare system using its name
  54309. * @param name defines the name to look for
  54310. * @returns the lens flare system or null if not found
  54311. */
  54312. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54313. /**
  54314. * Gets a lens flare system using its id
  54315. * @param id defines the id to look for
  54316. * @returns the lens flare system or null if not found
  54317. */
  54318. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54319. }
  54320. /**
  54321. * Defines the lens flare scene component responsible to manage any lens flares
  54322. * in a given scene.
  54323. */
  54324. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54325. /**
  54326. * The component name helpfull to identify the component in the list of scene components.
  54327. */
  54328. readonly name: string;
  54329. /**
  54330. * The scene the component belongs to.
  54331. */
  54332. scene: Scene;
  54333. /**
  54334. * Creates a new instance of the component for the given scene
  54335. * @param scene Defines the scene to register the component in
  54336. */
  54337. constructor(scene: Scene);
  54338. /**
  54339. * Registers the component in a given scene
  54340. */
  54341. register(): void;
  54342. /**
  54343. * Rebuilds the elements related to this component in case of
  54344. * context lost for instance.
  54345. */
  54346. rebuild(): void;
  54347. /**
  54348. * Adds all the elements from the container to the scene
  54349. * @param container the container holding the elements
  54350. */
  54351. addFromContainer(container: AbstractScene): void;
  54352. /**
  54353. * Removes all the elements in the container from the scene
  54354. * @param container contains the elements to remove
  54355. * @param dispose if the removed element should be disposed (default: false)
  54356. */
  54357. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54358. /**
  54359. * Serializes the component data to the specified json object
  54360. * @param serializationObject The object to serialize to
  54361. */
  54362. serialize(serializationObject: any): void;
  54363. /**
  54364. * Disposes the component and the associated ressources.
  54365. */
  54366. dispose(): void;
  54367. private _draw;
  54368. }
  54369. }
  54370. declare module BABYLON {
  54371. /** @hidden */
  54372. export var depthPixelShader: {
  54373. name: string;
  54374. shader: string;
  54375. };
  54376. }
  54377. declare module BABYLON {
  54378. /** @hidden */
  54379. export var depthVertexShader: {
  54380. name: string;
  54381. shader: string;
  54382. };
  54383. }
  54384. declare module BABYLON {
  54385. /**
  54386. * This represents a depth renderer in Babylon.
  54387. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54388. */
  54389. export class DepthRenderer {
  54390. private _scene;
  54391. private _depthMap;
  54392. private _effect;
  54393. private readonly _storeNonLinearDepth;
  54394. private readonly _clearColor;
  54395. /** Get if the depth renderer is using packed depth or not */
  54396. readonly isPacked: boolean;
  54397. private _cachedDefines;
  54398. private _camera;
  54399. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54400. enabled: boolean;
  54401. /**
  54402. * Specifiess that the depth renderer will only be used within
  54403. * the camera it is created for.
  54404. * This can help forcing its rendering during the camera processing.
  54405. */
  54406. useOnlyInActiveCamera: boolean;
  54407. /** @hidden */
  54408. static _SceneComponentInitialization: (scene: Scene) => void;
  54409. /**
  54410. * Instantiates a depth renderer
  54411. * @param scene The scene the renderer belongs to
  54412. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54413. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54414. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54415. */
  54416. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54417. /**
  54418. * Creates the depth rendering effect and checks if the effect is ready.
  54419. * @param subMesh The submesh to be used to render the depth map of
  54420. * @param useInstances If multiple world instances should be used
  54421. * @returns if the depth renderer is ready to render the depth map
  54422. */
  54423. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54424. /**
  54425. * Gets the texture which the depth map will be written to.
  54426. * @returns The depth map texture
  54427. */
  54428. getDepthMap(): RenderTargetTexture;
  54429. /**
  54430. * Disposes of the depth renderer.
  54431. */
  54432. dispose(): void;
  54433. }
  54434. }
  54435. declare module BABYLON {
  54436. /** @hidden */
  54437. export var minmaxReduxPixelShader: {
  54438. name: string;
  54439. shader: string;
  54440. };
  54441. }
  54442. declare module BABYLON {
  54443. /**
  54444. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54445. * and maximum values from all values of the texture.
  54446. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54447. * The source values are read from the red channel of the texture.
  54448. */
  54449. export class MinMaxReducer {
  54450. /**
  54451. * Observable triggered when the computation has been performed
  54452. */
  54453. onAfterReductionPerformed: Observable<{
  54454. min: number;
  54455. max: number;
  54456. }>;
  54457. protected _camera: Camera;
  54458. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54459. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54460. protected _postProcessManager: PostProcessManager;
  54461. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54462. protected _forceFullscreenViewport: boolean;
  54463. /**
  54464. * Creates a min/max reducer
  54465. * @param camera The camera to use for the post processes
  54466. */
  54467. constructor(camera: Camera);
  54468. /**
  54469. * Gets the texture used to read the values from.
  54470. */
  54471. get sourceTexture(): Nullable<RenderTargetTexture>;
  54472. /**
  54473. * Sets the source texture to read the values from.
  54474. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54475. * because in such textures '1' value must not be taken into account to compute the maximum
  54476. * as this value is used to clear the texture.
  54477. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54478. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54479. * @param depthRedux Indicates if the texture is a depth texture or not
  54480. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54481. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54482. */
  54483. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54484. /**
  54485. * Defines the refresh rate of the computation.
  54486. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54487. */
  54488. get refreshRate(): number;
  54489. set refreshRate(value: number);
  54490. protected _activated: boolean;
  54491. /**
  54492. * Gets the activation status of the reducer
  54493. */
  54494. get activated(): boolean;
  54495. /**
  54496. * Activates the reduction computation.
  54497. * When activated, the observers registered in onAfterReductionPerformed are
  54498. * called after the compuation is performed
  54499. */
  54500. activate(): void;
  54501. /**
  54502. * Deactivates the reduction computation.
  54503. */
  54504. deactivate(): void;
  54505. /**
  54506. * Disposes the min/max reducer
  54507. * @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.
  54508. */
  54509. dispose(disposeAll?: boolean): void;
  54510. }
  54511. }
  54512. declare module BABYLON {
  54513. /**
  54514. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54515. */
  54516. export class DepthReducer extends MinMaxReducer {
  54517. private _depthRenderer;
  54518. private _depthRendererId;
  54519. /**
  54520. * Gets the depth renderer used for the computation.
  54521. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54522. */
  54523. get depthRenderer(): Nullable<DepthRenderer>;
  54524. /**
  54525. * Creates a depth reducer
  54526. * @param camera The camera used to render the depth texture
  54527. */
  54528. constructor(camera: Camera);
  54529. /**
  54530. * Sets the depth renderer to use to generate the depth map
  54531. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54532. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54533. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54534. */
  54535. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54536. /** @hidden */
  54537. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54538. /**
  54539. * Activates the reduction computation.
  54540. * When activated, the observers registered in onAfterReductionPerformed are
  54541. * called after the compuation is performed
  54542. */
  54543. activate(): void;
  54544. /**
  54545. * Deactivates the reduction computation.
  54546. */
  54547. deactivate(): void;
  54548. /**
  54549. * Disposes the depth reducer
  54550. * @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.
  54551. */
  54552. dispose(disposeAll?: boolean): void;
  54553. }
  54554. }
  54555. declare module BABYLON {
  54556. /**
  54557. * A CSM implementation allowing casting shadows on large scenes.
  54558. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54559. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54560. */
  54561. export class CascadedShadowGenerator extends ShadowGenerator {
  54562. private static readonly frustumCornersNDCSpace;
  54563. /**
  54564. * Name of the CSM class
  54565. */
  54566. static CLASSNAME: string;
  54567. /**
  54568. * Defines the default number of cascades used by the CSM.
  54569. */
  54570. static readonly DEFAULT_CASCADES_COUNT: number;
  54571. /**
  54572. * Defines the minimum number of cascades used by the CSM.
  54573. */
  54574. static readonly MIN_CASCADES_COUNT: number;
  54575. /**
  54576. * Defines the maximum number of cascades used by the CSM.
  54577. */
  54578. static readonly MAX_CASCADES_COUNT: number;
  54579. protected _validateFilter(filter: number): number;
  54580. /**
  54581. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54582. */
  54583. penumbraDarkness: number;
  54584. private _numCascades;
  54585. /**
  54586. * Gets or set the number of cascades used by the CSM.
  54587. */
  54588. get numCascades(): number;
  54589. set numCascades(value: number);
  54590. /**
  54591. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54592. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54593. */
  54594. stabilizeCascades: boolean;
  54595. private _freezeShadowCastersBoundingInfo;
  54596. private _freezeShadowCastersBoundingInfoObservable;
  54597. /**
  54598. * Enables or disables the shadow casters bounding info computation.
  54599. * If your shadow casters don't move, you can disable this feature.
  54600. * If it is enabled, the bounding box computation is done every frame.
  54601. */
  54602. get freezeShadowCastersBoundingInfo(): boolean;
  54603. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54604. private _scbiMin;
  54605. private _scbiMax;
  54606. protected _computeShadowCastersBoundingInfo(): void;
  54607. protected _shadowCastersBoundingInfo: BoundingInfo;
  54608. /**
  54609. * Gets or sets the shadow casters bounding info.
  54610. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54611. * so that the system won't overwrite the bounds you provide
  54612. */
  54613. get shadowCastersBoundingInfo(): BoundingInfo;
  54614. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54615. protected _breaksAreDirty: boolean;
  54616. protected _minDistance: number;
  54617. protected _maxDistance: number;
  54618. /**
  54619. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54620. *
  54621. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54622. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54623. * @param min minimal distance for the breaks (default to 0.)
  54624. * @param max maximal distance for the breaks (default to 1.)
  54625. */
  54626. setMinMaxDistance(min: number, max: number): void;
  54627. /** Gets the minimal distance used in the cascade break computation */
  54628. get minDistance(): number;
  54629. /** Gets the maximal distance used in the cascade break computation */
  54630. get maxDistance(): number;
  54631. /**
  54632. * Gets the class name of that object
  54633. * @returns "CascadedShadowGenerator"
  54634. */
  54635. getClassName(): string;
  54636. private _cascadeMinExtents;
  54637. private _cascadeMaxExtents;
  54638. /**
  54639. * Gets a cascade minimum extents
  54640. * @param cascadeIndex index of the cascade
  54641. * @returns the minimum cascade extents
  54642. */
  54643. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54644. /**
  54645. * Gets a cascade maximum extents
  54646. * @param cascadeIndex index of the cascade
  54647. * @returns the maximum cascade extents
  54648. */
  54649. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54650. private _cascades;
  54651. private _currentLayer;
  54652. private _viewSpaceFrustumsZ;
  54653. private _viewMatrices;
  54654. private _projectionMatrices;
  54655. private _transformMatrices;
  54656. private _transformMatricesAsArray;
  54657. private _frustumLengths;
  54658. private _lightSizeUVCorrection;
  54659. private _depthCorrection;
  54660. private _frustumCornersWorldSpace;
  54661. private _frustumCenter;
  54662. private _shadowCameraPos;
  54663. private _shadowMaxZ;
  54664. /**
  54665. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54666. * It defaults to camera.maxZ
  54667. */
  54668. get shadowMaxZ(): number;
  54669. /**
  54670. * Sets the shadow max z distance.
  54671. */
  54672. set shadowMaxZ(value: number);
  54673. protected _debug: boolean;
  54674. /**
  54675. * Gets or sets the debug flag.
  54676. * When enabled, the cascades are materialized by different colors on the screen.
  54677. */
  54678. get debug(): boolean;
  54679. set debug(dbg: boolean);
  54680. private _depthClamp;
  54681. /**
  54682. * Gets or sets the depth clamping value.
  54683. *
  54684. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54685. * to account for the shadow casters far away.
  54686. *
  54687. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54688. */
  54689. get depthClamp(): boolean;
  54690. set depthClamp(value: boolean);
  54691. private _cascadeBlendPercentage;
  54692. /**
  54693. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54694. * It defaults to 0.1 (10% blending).
  54695. */
  54696. get cascadeBlendPercentage(): number;
  54697. set cascadeBlendPercentage(value: number);
  54698. private _lambda;
  54699. /**
  54700. * Gets or set the lambda parameter.
  54701. * This parameter is used to split the camera frustum and create the cascades.
  54702. * 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.
  54703. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54704. */
  54705. get lambda(): number;
  54706. set lambda(value: number);
  54707. /**
  54708. * Gets the view matrix corresponding to a given cascade
  54709. * @param cascadeNum cascade to retrieve the view matrix from
  54710. * @returns the cascade view matrix
  54711. */
  54712. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54713. /**
  54714. * Gets the projection matrix corresponding to a given cascade
  54715. * @param cascadeNum cascade to retrieve the projection matrix from
  54716. * @returns the cascade projection matrix
  54717. */
  54718. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54719. /**
  54720. * Gets the transformation matrix corresponding to a given cascade
  54721. * @param cascadeNum cascade to retrieve the transformation matrix from
  54722. * @returns the cascade transformation matrix
  54723. */
  54724. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54725. private _depthRenderer;
  54726. /**
  54727. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54728. *
  54729. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54730. *
  54731. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54732. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54733. * @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
  54734. */
  54735. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54736. private _depthReducer;
  54737. private _autoCalcDepthBounds;
  54738. /**
  54739. * Gets or sets the autoCalcDepthBounds property.
  54740. *
  54741. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54742. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54743. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54744. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54745. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54746. */
  54747. get autoCalcDepthBounds(): boolean;
  54748. set autoCalcDepthBounds(value: boolean);
  54749. /**
  54750. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54751. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54752. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54753. * for setting the refresh rate on the renderer yourself!
  54754. */
  54755. get autoCalcDepthBoundsRefreshRate(): number;
  54756. set autoCalcDepthBoundsRefreshRate(value: number);
  54757. /**
  54758. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54759. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54760. * you change the camera near/far planes!
  54761. */
  54762. splitFrustum(): void;
  54763. private _splitFrustum;
  54764. private _computeMatrices;
  54765. private _computeFrustumInWorldSpace;
  54766. private _computeCascadeFrustum;
  54767. /**
  54768. * Support test.
  54769. */
  54770. static get IsSupported(): boolean;
  54771. /** @hidden */
  54772. static _SceneComponentInitialization: (scene: Scene) => void;
  54773. /**
  54774. * Creates a Cascaded Shadow Generator object.
  54775. * A ShadowGenerator is the required tool to use the shadows.
  54776. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54777. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54778. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54779. * @param light The directional light object generating the shadows.
  54780. * @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.
  54781. */
  54782. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54783. protected _initializeGenerator(): void;
  54784. protected _createTargetRenderTexture(): void;
  54785. protected _initializeShadowMap(): void;
  54786. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54787. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54788. /**
  54789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54790. * @param defines Defines of the material we want to update
  54791. * @param lightIndex Index of the light in the enabled light list of the material
  54792. */
  54793. prepareDefines(defines: any, lightIndex: number): void;
  54794. /**
  54795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54796. * defined in the generator but impacting the effect).
  54797. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54798. * @param effect The effect we are binfing the information for
  54799. */
  54800. bindShadowLight(lightIndex: string, effect: Effect): void;
  54801. /**
  54802. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54803. * (eq to view projection * shadow projection matrices)
  54804. * @returns The transform matrix used to create the shadow map
  54805. */
  54806. getTransformMatrix(): Matrix;
  54807. /**
  54808. * Disposes the ShadowGenerator.
  54809. * Returns nothing.
  54810. */
  54811. dispose(): void;
  54812. /**
  54813. * Serializes the shadow generator setup to a json object.
  54814. * @returns The serialized JSON object
  54815. */
  54816. serialize(): any;
  54817. /**
  54818. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54819. * @param parsedShadowGenerator The JSON object to parse
  54820. * @param scene The scene to create the shadow map for
  54821. * @returns The parsed shadow generator
  54822. */
  54823. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54824. }
  54825. }
  54826. declare module BABYLON {
  54827. /**
  54828. * Defines the shadow generator component responsible to manage any shadow generators
  54829. * in a given scene.
  54830. */
  54831. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54832. /**
  54833. * The component name helpfull to identify the component in the list of scene components.
  54834. */
  54835. readonly name: string;
  54836. /**
  54837. * The scene the component belongs to.
  54838. */
  54839. scene: Scene;
  54840. /**
  54841. * Creates a new instance of the component for the given scene
  54842. * @param scene Defines the scene to register the component in
  54843. */
  54844. constructor(scene: Scene);
  54845. /**
  54846. * Registers the component in a given scene
  54847. */
  54848. register(): void;
  54849. /**
  54850. * Rebuilds the elements related to this component in case of
  54851. * context lost for instance.
  54852. */
  54853. rebuild(): void;
  54854. /**
  54855. * Serializes the component data to the specified json object
  54856. * @param serializationObject The object to serialize to
  54857. */
  54858. serialize(serializationObject: any): void;
  54859. /**
  54860. * Adds all the elements from the container to the scene
  54861. * @param container the container holding the elements
  54862. */
  54863. addFromContainer(container: AbstractScene): void;
  54864. /**
  54865. * Removes all the elements in the container from the scene
  54866. * @param container contains the elements to remove
  54867. * @param dispose if the removed element should be disposed (default: false)
  54868. */
  54869. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54870. /**
  54871. * Rebuilds the elements related to this component in case of
  54872. * context lost for instance.
  54873. */
  54874. dispose(): void;
  54875. private _gatherRenderTargets;
  54876. }
  54877. }
  54878. declare module BABYLON {
  54879. /**
  54880. * A point light is a light defined by an unique point in world space.
  54881. * The light is emitted in every direction from this point.
  54882. * A good example of a point light is a standard light bulb.
  54883. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54884. */
  54885. export class PointLight extends ShadowLight {
  54886. private _shadowAngle;
  54887. /**
  54888. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54889. * This specifies what angle the shadow will use to be created.
  54890. *
  54891. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54892. */
  54893. get shadowAngle(): number;
  54894. /**
  54895. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54896. * This specifies what angle the shadow will use to be created.
  54897. *
  54898. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54899. */
  54900. set shadowAngle(value: number);
  54901. /**
  54902. * Gets the direction if it has been set.
  54903. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54904. */
  54905. get direction(): Vector3;
  54906. /**
  54907. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54908. */
  54909. set direction(value: Vector3);
  54910. /**
  54911. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54912. * A PointLight emits the light in every direction.
  54913. * It can cast shadows.
  54914. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54915. * ```javascript
  54916. * var pointLight = new PointLight("pl", camera.position, scene);
  54917. * ```
  54918. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54919. * @param name The light friendly name
  54920. * @param position The position of the point light in the scene
  54921. * @param scene The scene the lights belongs to
  54922. */
  54923. constructor(name: string, position: Vector3, scene: Scene);
  54924. /**
  54925. * Returns the string "PointLight"
  54926. * @returns the class name
  54927. */
  54928. getClassName(): string;
  54929. /**
  54930. * Returns the integer 0.
  54931. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54932. */
  54933. getTypeID(): number;
  54934. /**
  54935. * Specifies wether or not the shadowmap should be a cube texture.
  54936. * @returns true if the shadowmap needs to be a cube texture.
  54937. */
  54938. needCube(): boolean;
  54939. /**
  54940. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54941. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54942. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54943. */
  54944. getShadowDirection(faceIndex?: number): Vector3;
  54945. /**
  54946. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54947. * - fov = PI / 2
  54948. * - aspect ratio : 1.0
  54949. * - z-near and far equal to the active camera minZ and maxZ.
  54950. * Returns the PointLight.
  54951. */
  54952. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54953. protected _buildUniformLayout(): void;
  54954. /**
  54955. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54956. * @param effect The effect to update
  54957. * @param lightIndex The index of the light in the effect to update
  54958. * @returns The point light
  54959. */
  54960. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54961. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54962. /**
  54963. * Prepares the list of defines specific to the light type.
  54964. * @param defines the list of defines
  54965. * @param lightIndex defines the index of the light for the effect
  54966. */
  54967. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54968. }
  54969. }
  54970. declare module BABYLON {
  54971. /**
  54972. * Header information of HDR texture files.
  54973. */
  54974. export interface HDRInfo {
  54975. /**
  54976. * The height of the texture in pixels.
  54977. */
  54978. height: number;
  54979. /**
  54980. * The width of the texture in pixels.
  54981. */
  54982. width: number;
  54983. /**
  54984. * The index of the beginning of the data in the binary file.
  54985. */
  54986. dataPosition: number;
  54987. }
  54988. /**
  54989. * This groups tools to convert HDR texture to native colors array.
  54990. */
  54991. export class HDRTools {
  54992. private static Ldexp;
  54993. private static Rgbe2float;
  54994. private static readStringLine;
  54995. /**
  54996. * Reads header information from an RGBE texture stored in a native array.
  54997. * More information on this format are available here:
  54998. * https://en.wikipedia.org/wiki/RGBE_image_format
  54999. *
  55000. * @param uint8array The binary file stored in native array.
  55001. * @return The header information.
  55002. */
  55003. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55004. /**
  55005. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55006. * This RGBE texture needs to store the information as a panorama.
  55007. *
  55008. * More information on this format are available here:
  55009. * https://en.wikipedia.org/wiki/RGBE_image_format
  55010. *
  55011. * @param buffer The binary file stored in an array buffer.
  55012. * @param size The expected size of the extracted cubemap.
  55013. * @return The Cube Map information.
  55014. */
  55015. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55016. /**
  55017. * Returns the pixels data extracted from an RGBE texture.
  55018. * This pixels will be stored left to right up to down in the R G B order in one array.
  55019. *
  55020. * More information on this format are available here:
  55021. * https://en.wikipedia.org/wiki/RGBE_image_format
  55022. *
  55023. * @param uint8array The binary file stored in an array buffer.
  55024. * @param hdrInfo The header information of the file.
  55025. * @return The pixels data in RGB right to left up to down order.
  55026. */
  55027. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55028. private static RGBE_ReadPixels_RLE;
  55029. }
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * This represents a texture coming from an HDR input.
  55034. *
  55035. * The only supported format is currently panorama picture stored in RGBE format.
  55036. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55037. */
  55038. export class HDRCubeTexture extends BaseTexture {
  55039. private static _facesMapping;
  55040. private _generateHarmonics;
  55041. private _noMipmap;
  55042. private _textureMatrix;
  55043. private _size;
  55044. private _onLoad;
  55045. private _onError;
  55046. /**
  55047. * The texture URL.
  55048. */
  55049. url: string;
  55050. /**
  55051. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55052. */
  55053. coordinatesMode: number;
  55054. protected _isBlocking: boolean;
  55055. /**
  55056. * Sets wether or not the texture is blocking during loading.
  55057. */
  55058. set isBlocking(value: boolean);
  55059. /**
  55060. * Gets wether or not the texture is blocking during loading.
  55061. */
  55062. get isBlocking(): boolean;
  55063. protected _rotationY: number;
  55064. /**
  55065. * Sets texture matrix rotation angle around Y axis in radians.
  55066. */
  55067. set rotationY(value: number);
  55068. /**
  55069. * Gets texture matrix rotation angle around Y axis radians.
  55070. */
  55071. get rotationY(): number;
  55072. /**
  55073. * Gets or sets the center of the bounding box associated with the cube texture
  55074. * It must define where the camera used to render the texture was set
  55075. */
  55076. boundingBoxPosition: Vector3;
  55077. private _boundingBoxSize;
  55078. /**
  55079. * Gets or sets the size of the bounding box associated with the cube texture
  55080. * When defined, the cubemap will switch to local mode
  55081. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55082. * @example https://www.babylonjs-playground.com/#RNASML
  55083. */
  55084. set boundingBoxSize(value: Vector3);
  55085. get boundingBoxSize(): Vector3;
  55086. /**
  55087. * Instantiates an HDRTexture from the following parameters.
  55088. *
  55089. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55090. * @param scene The scene the texture will be used in
  55091. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55092. * @param noMipmap Forces to not generate the mipmap if true
  55093. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55094. * @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)
  55095. * @param reserved Reserved flag for internal use.
  55096. */
  55097. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55098. /**
  55099. * Get the current class name of the texture useful for serialization or dynamic coding.
  55100. * @returns "HDRCubeTexture"
  55101. */
  55102. getClassName(): string;
  55103. /**
  55104. * Occurs when the file is raw .hdr file.
  55105. */
  55106. private loadTexture;
  55107. clone(): HDRCubeTexture;
  55108. delayLoad(): void;
  55109. /**
  55110. * Get the texture reflection matrix used to rotate/transform the reflection.
  55111. * @returns the reflection matrix
  55112. */
  55113. getReflectionTextureMatrix(): Matrix;
  55114. /**
  55115. * Set the texture reflection matrix used to rotate/transform the reflection.
  55116. * @param value Define the reflection matrix to set
  55117. */
  55118. setReflectionTextureMatrix(value: Matrix): void;
  55119. /**
  55120. * Parses a JSON representation of an HDR Texture in order to create the texture
  55121. * @param parsedTexture Define the JSON representation
  55122. * @param scene Define the scene the texture should be created in
  55123. * @param rootUrl Define the root url in case we need to load relative dependencies
  55124. * @returns the newly created texture after parsing
  55125. */
  55126. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55127. serialize(): any;
  55128. }
  55129. }
  55130. declare module BABYLON {
  55131. /**
  55132. * Class used to control physics engine
  55133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55134. */
  55135. export class PhysicsEngine implements IPhysicsEngine {
  55136. private _physicsPlugin;
  55137. /**
  55138. * Global value used to control the smallest number supported by the simulation
  55139. */
  55140. static Epsilon: number;
  55141. private _impostors;
  55142. private _joints;
  55143. private _subTimeStep;
  55144. /**
  55145. * Gets the gravity vector used by the simulation
  55146. */
  55147. gravity: Vector3;
  55148. /**
  55149. * Factory used to create the default physics plugin.
  55150. * @returns The default physics plugin
  55151. */
  55152. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55153. /**
  55154. * Creates a new Physics Engine
  55155. * @param gravity defines the gravity vector used by the simulation
  55156. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55157. */
  55158. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55159. /**
  55160. * Sets the gravity vector used by the simulation
  55161. * @param gravity defines the gravity vector to use
  55162. */
  55163. setGravity(gravity: Vector3): void;
  55164. /**
  55165. * Set the time step of the physics engine.
  55166. * Default is 1/60.
  55167. * To slow it down, enter 1/600 for example.
  55168. * To speed it up, 1/30
  55169. * @param newTimeStep defines the new timestep to apply to this world.
  55170. */
  55171. setTimeStep(newTimeStep?: number): void;
  55172. /**
  55173. * Get the time step of the physics engine.
  55174. * @returns the current time step
  55175. */
  55176. getTimeStep(): number;
  55177. /**
  55178. * Set the sub time step of the physics engine.
  55179. * Default is 0 meaning there is no sub steps
  55180. * To increase physics resolution precision, set a small value (like 1 ms)
  55181. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55182. */
  55183. setSubTimeStep(subTimeStep?: number): void;
  55184. /**
  55185. * Get the sub time step of the physics engine.
  55186. * @returns the current sub time step
  55187. */
  55188. getSubTimeStep(): number;
  55189. /**
  55190. * Release all resources
  55191. */
  55192. dispose(): void;
  55193. /**
  55194. * Gets the name of the current physics plugin
  55195. * @returns the name of the plugin
  55196. */
  55197. getPhysicsPluginName(): string;
  55198. /**
  55199. * Adding a new impostor for the impostor tracking.
  55200. * This will be done by the impostor itself.
  55201. * @param impostor the impostor to add
  55202. */
  55203. addImpostor(impostor: PhysicsImpostor): void;
  55204. /**
  55205. * Remove an impostor from the engine.
  55206. * This impostor and its mesh will not longer be updated by the physics engine.
  55207. * @param impostor the impostor to remove
  55208. */
  55209. removeImpostor(impostor: PhysicsImpostor): void;
  55210. /**
  55211. * Add a joint to the physics engine
  55212. * @param mainImpostor defines the main impostor to which the joint is added.
  55213. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55214. * @param joint defines the joint that will connect both impostors.
  55215. */
  55216. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55217. /**
  55218. * Removes a joint from the simulation
  55219. * @param mainImpostor defines the impostor used with the joint
  55220. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55221. * @param joint defines the joint to remove
  55222. */
  55223. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55224. /**
  55225. * Called by the scene. No need to call it.
  55226. * @param delta defines the timespam between frames
  55227. */
  55228. _step(delta: number): void;
  55229. /**
  55230. * Gets the current plugin used to run the simulation
  55231. * @returns current plugin
  55232. */
  55233. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55234. /**
  55235. * Gets the list of physic impostors
  55236. * @returns an array of PhysicsImpostor
  55237. */
  55238. getImpostors(): Array<PhysicsImpostor>;
  55239. /**
  55240. * Gets the impostor for a physics enabled object
  55241. * @param object defines the object impersonated by the impostor
  55242. * @returns the PhysicsImpostor or null if not found
  55243. */
  55244. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55245. /**
  55246. * Gets the impostor for a physics body object
  55247. * @param body defines physics body used by the impostor
  55248. * @returns the PhysicsImpostor or null if not found
  55249. */
  55250. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55251. /**
  55252. * Does a raycast in the physics world
  55253. * @param from when should the ray start?
  55254. * @param to when should the ray end?
  55255. * @returns PhysicsRaycastResult
  55256. */
  55257. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55258. }
  55259. }
  55260. declare module BABYLON {
  55261. /** @hidden */
  55262. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55263. private _useDeltaForWorldStep;
  55264. world: any;
  55265. name: string;
  55266. private _physicsMaterials;
  55267. private _fixedTimeStep;
  55268. private _cannonRaycastResult;
  55269. private _raycastResult;
  55270. private _physicsBodysToRemoveAfterStep;
  55271. BJSCANNON: any;
  55272. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55273. setGravity(gravity: Vector3): void;
  55274. setTimeStep(timeStep: number): void;
  55275. getTimeStep(): number;
  55276. executeStep(delta: number): void;
  55277. private _removeMarkedPhysicsBodiesFromWorld;
  55278. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55279. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55280. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55281. private _processChildMeshes;
  55282. removePhysicsBody(impostor: PhysicsImpostor): void;
  55283. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55284. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55285. private _addMaterial;
  55286. private _checkWithEpsilon;
  55287. private _createShape;
  55288. private _createHeightmap;
  55289. private _minus90X;
  55290. private _plus90X;
  55291. private _tmpPosition;
  55292. private _tmpDeltaPosition;
  55293. private _tmpUnityRotation;
  55294. private _updatePhysicsBodyTransformation;
  55295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55296. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55297. isSupported(): boolean;
  55298. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55299. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55300. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55301. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55302. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55303. getBodyMass(impostor: PhysicsImpostor): number;
  55304. getBodyFriction(impostor: PhysicsImpostor): number;
  55305. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55306. getBodyRestitution(impostor: PhysicsImpostor): number;
  55307. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55308. sleepBody(impostor: PhysicsImpostor): void;
  55309. wakeUpBody(impostor: PhysicsImpostor): void;
  55310. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55311. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55312. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55313. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55314. getRadius(impostor: PhysicsImpostor): number;
  55315. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55316. dispose(): void;
  55317. private _extendNamespace;
  55318. /**
  55319. * Does a raycast in the physics world
  55320. * @param from when should the ray start?
  55321. * @param to when should the ray end?
  55322. * @returns PhysicsRaycastResult
  55323. */
  55324. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55325. }
  55326. }
  55327. declare module BABYLON {
  55328. /** @hidden */
  55329. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55330. world: any;
  55331. name: string;
  55332. BJSOIMO: any;
  55333. private _raycastResult;
  55334. constructor(iterations?: number, oimoInjection?: any);
  55335. setGravity(gravity: Vector3): void;
  55336. setTimeStep(timeStep: number): void;
  55337. getTimeStep(): number;
  55338. private _tmpImpostorsArray;
  55339. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55341. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55343. private _tmpPositionVector;
  55344. removePhysicsBody(impostor: PhysicsImpostor): void;
  55345. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55346. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55347. isSupported(): boolean;
  55348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55350. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55351. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55352. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55353. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55354. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55355. getBodyMass(impostor: PhysicsImpostor): number;
  55356. getBodyFriction(impostor: PhysicsImpostor): number;
  55357. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55358. getBodyRestitution(impostor: PhysicsImpostor): number;
  55359. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55360. sleepBody(impostor: PhysicsImpostor): void;
  55361. wakeUpBody(impostor: PhysicsImpostor): void;
  55362. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55363. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55364. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55365. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55366. getRadius(impostor: PhysicsImpostor): number;
  55367. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55368. dispose(): void;
  55369. /**
  55370. * Does a raycast in the physics world
  55371. * @param from when should the ray start?
  55372. * @param to when should the ray end?
  55373. * @returns PhysicsRaycastResult
  55374. */
  55375. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55376. }
  55377. }
  55378. declare module BABYLON {
  55379. /**
  55380. * Class containing static functions to help procedurally build meshes
  55381. */
  55382. export class RibbonBuilder {
  55383. /**
  55384. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55385. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55386. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55387. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55388. * * 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
  55389. * * 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
  55390. * * 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
  55391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55392. * * 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
  55393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55394. * * 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
  55395. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55396. * * 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
  55397. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55399. * @param name defines the name of the mesh
  55400. * @param options defines the options used to create the mesh
  55401. * @param scene defines the hosting scene
  55402. * @returns the ribbon mesh
  55403. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55405. */
  55406. static CreateRibbon(name: string, options: {
  55407. pathArray: Vector3[][];
  55408. closeArray?: boolean;
  55409. closePath?: boolean;
  55410. offset?: number;
  55411. updatable?: boolean;
  55412. sideOrientation?: number;
  55413. frontUVs?: Vector4;
  55414. backUVs?: Vector4;
  55415. instance?: Mesh;
  55416. invertUV?: boolean;
  55417. uvs?: Vector2[];
  55418. colors?: Color4[];
  55419. }, scene?: Nullable<Scene>): Mesh;
  55420. }
  55421. }
  55422. declare module BABYLON {
  55423. /**
  55424. * Class containing static functions to help procedurally build meshes
  55425. */
  55426. export class ShapeBuilder {
  55427. /**
  55428. * 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.
  55429. * * 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.
  55430. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55431. * * 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.
  55432. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55433. * * 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
  55434. * * 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
  55435. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55437. * * 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
  55438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55440. * @param name defines the name of the mesh
  55441. * @param options defines the options used to create the mesh
  55442. * @param scene defines the hosting scene
  55443. * @returns the extruded shape mesh
  55444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55446. */
  55447. static ExtrudeShape(name: string, options: {
  55448. shape: Vector3[];
  55449. path: Vector3[];
  55450. scale?: number;
  55451. rotation?: number;
  55452. cap?: number;
  55453. updatable?: boolean;
  55454. sideOrientation?: number;
  55455. frontUVs?: Vector4;
  55456. backUVs?: Vector4;
  55457. instance?: Mesh;
  55458. invertUV?: boolean;
  55459. }, scene?: Nullable<Scene>): Mesh;
  55460. /**
  55461. * Creates an custom extruded shape mesh.
  55462. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55463. * * 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.
  55464. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55465. * * 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
  55466. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55467. * * 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
  55468. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55469. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55470. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55471. * * 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
  55472. * * 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
  55473. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55475. * * 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
  55476. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55478. * @param name defines the name of the mesh
  55479. * @param options defines the options used to create the mesh
  55480. * @param scene defines the hosting scene
  55481. * @returns the custom extruded shape mesh
  55482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55483. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55485. */
  55486. static ExtrudeShapeCustom(name: string, options: {
  55487. shape: Vector3[];
  55488. path: Vector3[];
  55489. scaleFunction?: any;
  55490. rotationFunction?: any;
  55491. ribbonCloseArray?: boolean;
  55492. ribbonClosePath?: boolean;
  55493. cap?: number;
  55494. updatable?: boolean;
  55495. sideOrientation?: number;
  55496. frontUVs?: Vector4;
  55497. backUVs?: Vector4;
  55498. instance?: Mesh;
  55499. invertUV?: boolean;
  55500. }, scene?: Nullable<Scene>): Mesh;
  55501. private static _ExtrudeShapeGeneric;
  55502. }
  55503. }
  55504. declare module BABYLON {
  55505. /**
  55506. * AmmoJS Physics plugin
  55507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55508. * @see https://github.com/kripken/ammo.js/
  55509. */
  55510. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55511. private _useDeltaForWorldStep;
  55512. /**
  55513. * Reference to the Ammo library
  55514. */
  55515. bjsAMMO: any;
  55516. /**
  55517. * Created ammoJS world which physics bodies are added to
  55518. */
  55519. world: any;
  55520. /**
  55521. * Name of the plugin
  55522. */
  55523. name: string;
  55524. private _timeStep;
  55525. private _fixedTimeStep;
  55526. private _maxSteps;
  55527. private _tmpQuaternion;
  55528. private _tmpAmmoTransform;
  55529. private _tmpAmmoQuaternion;
  55530. private _tmpAmmoConcreteContactResultCallback;
  55531. private _collisionConfiguration;
  55532. private _dispatcher;
  55533. private _overlappingPairCache;
  55534. private _solver;
  55535. private _softBodySolver;
  55536. private _tmpAmmoVectorA;
  55537. private _tmpAmmoVectorB;
  55538. private _tmpAmmoVectorC;
  55539. private _tmpAmmoVectorD;
  55540. private _tmpContactCallbackResult;
  55541. private _tmpAmmoVectorRCA;
  55542. private _tmpAmmoVectorRCB;
  55543. private _raycastResult;
  55544. private static readonly DISABLE_COLLISION_FLAG;
  55545. private static readonly KINEMATIC_FLAG;
  55546. private static readonly DISABLE_DEACTIVATION_FLAG;
  55547. /**
  55548. * Initializes the ammoJS plugin
  55549. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55550. * @param ammoInjection can be used to inject your own ammo reference
  55551. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55552. */
  55553. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55554. /**
  55555. * Sets the gravity of the physics world (m/(s^2))
  55556. * @param gravity Gravity to set
  55557. */
  55558. setGravity(gravity: Vector3): void;
  55559. /**
  55560. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55561. * @param timeStep timestep to use in seconds
  55562. */
  55563. setTimeStep(timeStep: number): void;
  55564. /**
  55565. * 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)
  55566. * @param fixedTimeStep fixedTimeStep to use in seconds
  55567. */
  55568. setFixedTimeStep(fixedTimeStep: number): void;
  55569. /**
  55570. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55571. * @param maxSteps the maximum number of steps by the physics engine per frame
  55572. */
  55573. setMaxSteps(maxSteps: number): void;
  55574. /**
  55575. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55576. * @returns the current timestep in seconds
  55577. */
  55578. getTimeStep(): number;
  55579. /**
  55580. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55581. */
  55582. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55583. private _isImpostorInContact;
  55584. private _isImpostorPairInContact;
  55585. private _stepSimulation;
  55586. /**
  55587. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55588. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55589. * After the step the babylon meshes are set to the position of the physics imposters
  55590. * @param delta amount of time to step forward
  55591. * @param impostors array of imposters to update before/after the step
  55592. */
  55593. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55594. /**
  55595. * Update babylon mesh to match physics world object
  55596. * @param impostor imposter to match
  55597. */
  55598. private _afterSoftStep;
  55599. /**
  55600. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55601. * @param impostor imposter to match
  55602. */
  55603. private _ropeStep;
  55604. /**
  55605. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55606. * @param impostor imposter to match
  55607. */
  55608. private _softbodyOrClothStep;
  55609. private _tmpVector;
  55610. private _tmpMatrix;
  55611. /**
  55612. * Applies an impulse on the imposter
  55613. * @param impostor imposter to apply impulse to
  55614. * @param force amount of force to be applied to the imposter
  55615. * @param contactPoint the location to apply the impulse on the imposter
  55616. */
  55617. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55618. /**
  55619. * Applies a force on the imposter
  55620. * @param impostor imposter to apply force
  55621. * @param force amount of force to be applied to the imposter
  55622. * @param contactPoint the location to apply the force on the imposter
  55623. */
  55624. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55625. /**
  55626. * Creates a physics body using the plugin
  55627. * @param impostor the imposter to create the physics body on
  55628. */
  55629. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55630. /**
  55631. * Removes the physics body from the imposter and disposes of the body's memory
  55632. * @param impostor imposter to remove the physics body from
  55633. */
  55634. removePhysicsBody(impostor: PhysicsImpostor): void;
  55635. /**
  55636. * Generates a joint
  55637. * @param impostorJoint the imposter joint to create the joint with
  55638. */
  55639. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55640. /**
  55641. * Removes a joint
  55642. * @param impostorJoint the imposter joint to remove the joint from
  55643. */
  55644. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55645. private _addMeshVerts;
  55646. /**
  55647. * Initialise the soft body vertices to match its object's (mesh) vertices
  55648. * Softbody vertices (nodes) are in world space and to match this
  55649. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55650. * @param impostor to create the softbody for
  55651. */
  55652. private _softVertexData;
  55653. /**
  55654. * Create an impostor's soft body
  55655. * @param impostor to create the softbody for
  55656. */
  55657. private _createSoftbody;
  55658. /**
  55659. * Create cloth for an impostor
  55660. * @param impostor to create the softbody for
  55661. */
  55662. private _createCloth;
  55663. /**
  55664. * Create rope for an impostor
  55665. * @param impostor to create the softbody for
  55666. */
  55667. private _createRope;
  55668. /**
  55669. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55670. * @param impostor to create the custom physics shape for
  55671. */
  55672. private _createCustom;
  55673. private _addHullVerts;
  55674. private _createShape;
  55675. /**
  55676. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55677. * @param impostor imposter containing the physics body and babylon object
  55678. */
  55679. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55680. /**
  55681. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55682. * @param impostor imposter containing the physics body and babylon object
  55683. * @param newPosition new position
  55684. * @param newRotation new rotation
  55685. */
  55686. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55687. /**
  55688. * If this plugin is supported
  55689. * @returns true if its supported
  55690. */
  55691. isSupported(): boolean;
  55692. /**
  55693. * Sets the linear velocity of the physics body
  55694. * @param impostor imposter to set the velocity on
  55695. * @param velocity velocity to set
  55696. */
  55697. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55698. /**
  55699. * Sets the angular velocity of the physics body
  55700. * @param impostor imposter to set the velocity on
  55701. * @param velocity velocity to set
  55702. */
  55703. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55704. /**
  55705. * gets the linear velocity
  55706. * @param impostor imposter to get linear velocity from
  55707. * @returns linear velocity
  55708. */
  55709. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55710. /**
  55711. * gets the angular velocity
  55712. * @param impostor imposter to get angular velocity from
  55713. * @returns angular velocity
  55714. */
  55715. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55716. /**
  55717. * Sets the mass of physics body
  55718. * @param impostor imposter to set the mass on
  55719. * @param mass mass to set
  55720. */
  55721. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55722. /**
  55723. * Gets the mass of the physics body
  55724. * @param impostor imposter to get the mass from
  55725. * @returns mass
  55726. */
  55727. getBodyMass(impostor: PhysicsImpostor): number;
  55728. /**
  55729. * Gets friction of the impostor
  55730. * @param impostor impostor to get friction from
  55731. * @returns friction value
  55732. */
  55733. getBodyFriction(impostor: PhysicsImpostor): number;
  55734. /**
  55735. * Sets friction of the impostor
  55736. * @param impostor impostor to set friction on
  55737. * @param friction friction value
  55738. */
  55739. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55740. /**
  55741. * Gets restitution of the impostor
  55742. * @param impostor impostor to get restitution from
  55743. * @returns restitution value
  55744. */
  55745. getBodyRestitution(impostor: PhysicsImpostor): number;
  55746. /**
  55747. * Sets resitution of the impostor
  55748. * @param impostor impostor to set resitution on
  55749. * @param restitution resitution value
  55750. */
  55751. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55752. /**
  55753. * Gets pressure inside the impostor
  55754. * @param impostor impostor to get pressure from
  55755. * @returns pressure value
  55756. */
  55757. getBodyPressure(impostor: PhysicsImpostor): number;
  55758. /**
  55759. * Sets pressure inside a soft body impostor
  55760. * Cloth and rope must remain 0 pressure
  55761. * @param impostor impostor to set pressure on
  55762. * @param pressure pressure value
  55763. */
  55764. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55765. /**
  55766. * Gets stiffness of the impostor
  55767. * @param impostor impostor to get stiffness from
  55768. * @returns pressure value
  55769. */
  55770. getBodyStiffness(impostor: PhysicsImpostor): number;
  55771. /**
  55772. * Sets stiffness of the impostor
  55773. * @param impostor impostor to set stiffness on
  55774. * @param stiffness stiffness value from 0 to 1
  55775. */
  55776. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55777. /**
  55778. * Gets velocityIterations of the impostor
  55779. * @param impostor impostor to get velocity iterations from
  55780. * @returns velocityIterations value
  55781. */
  55782. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55783. /**
  55784. * Sets velocityIterations of the impostor
  55785. * @param impostor impostor to set velocity iterations on
  55786. * @param velocityIterations velocityIterations value
  55787. */
  55788. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55789. /**
  55790. * Gets positionIterations of the impostor
  55791. * @param impostor impostor to get position iterations from
  55792. * @returns positionIterations value
  55793. */
  55794. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55795. /**
  55796. * Sets positionIterations of the impostor
  55797. * @param impostor impostor to set position on
  55798. * @param positionIterations positionIterations value
  55799. */
  55800. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55801. /**
  55802. * Append an anchor to a cloth object
  55803. * @param impostor is the cloth impostor to add anchor to
  55804. * @param otherImpostor is the rigid impostor to anchor to
  55805. * @param width ratio across width from 0 to 1
  55806. * @param height ratio up height from 0 to 1
  55807. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55808. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55809. */
  55810. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55811. /**
  55812. * Append an hook to a rope object
  55813. * @param impostor is the rope impostor to add hook to
  55814. * @param otherImpostor is the rigid impostor to hook to
  55815. * @param length ratio along the rope from 0 to 1
  55816. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55817. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55818. */
  55819. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55820. /**
  55821. * Sleeps the physics body and stops it from being active
  55822. * @param impostor impostor to sleep
  55823. */
  55824. sleepBody(impostor: PhysicsImpostor): void;
  55825. /**
  55826. * Activates the physics body
  55827. * @param impostor impostor to activate
  55828. */
  55829. wakeUpBody(impostor: PhysicsImpostor): void;
  55830. /**
  55831. * Updates the distance parameters of the joint
  55832. * @param joint joint to update
  55833. * @param maxDistance maximum distance of the joint
  55834. * @param minDistance minimum distance of the joint
  55835. */
  55836. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55837. /**
  55838. * Sets a motor on the joint
  55839. * @param joint joint to set motor on
  55840. * @param speed speed of the motor
  55841. * @param maxForce maximum force of the motor
  55842. * @param motorIndex index of the motor
  55843. */
  55844. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55845. /**
  55846. * Sets the motors limit
  55847. * @param joint joint to set limit on
  55848. * @param upperLimit upper limit
  55849. * @param lowerLimit lower limit
  55850. */
  55851. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55852. /**
  55853. * Syncs the position and rotation of a mesh with the impostor
  55854. * @param mesh mesh to sync
  55855. * @param impostor impostor to update the mesh with
  55856. */
  55857. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55858. /**
  55859. * Gets the radius of the impostor
  55860. * @param impostor impostor to get radius from
  55861. * @returns the radius
  55862. */
  55863. getRadius(impostor: PhysicsImpostor): number;
  55864. /**
  55865. * Gets the box size of the impostor
  55866. * @param impostor impostor to get box size from
  55867. * @param result the resulting box size
  55868. */
  55869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55870. /**
  55871. * Disposes of the impostor
  55872. */
  55873. dispose(): void;
  55874. /**
  55875. * Does a raycast in the physics world
  55876. * @param from when should the ray start?
  55877. * @param to when should the ray end?
  55878. * @returns PhysicsRaycastResult
  55879. */
  55880. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55881. }
  55882. }
  55883. declare module BABYLON {
  55884. interface AbstractScene {
  55885. /**
  55886. * The list of reflection probes added to the scene
  55887. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55888. */
  55889. reflectionProbes: Array<ReflectionProbe>;
  55890. /**
  55891. * Removes the given reflection probe from this scene.
  55892. * @param toRemove The reflection probe to remove
  55893. * @returns The index of the removed reflection probe
  55894. */
  55895. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55896. /**
  55897. * Adds the given reflection probe to this scene.
  55898. * @param newReflectionProbe The reflection probe to add
  55899. */
  55900. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55901. }
  55902. /**
  55903. * Class used to generate realtime reflection / refraction cube textures
  55904. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55905. */
  55906. export class ReflectionProbe {
  55907. /** defines the name of the probe */
  55908. name: string;
  55909. private _scene;
  55910. private _renderTargetTexture;
  55911. private _projectionMatrix;
  55912. private _viewMatrix;
  55913. private _target;
  55914. private _add;
  55915. private _attachedMesh;
  55916. private _invertYAxis;
  55917. /** Gets or sets probe position (center of the cube map) */
  55918. position: Vector3;
  55919. /**
  55920. * Creates a new reflection probe
  55921. * @param name defines the name of the probe
  55922. * @param size defines the texture resolution (for each face)
  55923. * @param scene defines the hosting scene
  55924. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55925. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55926. */
  55927. constructor(
  55928. /** defines the name of the probe */
  55929. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55930. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55931. get samples(): number;
  55932. set samples(value: number);
  55933. /** Gets or sets the refresh rate to use (on every frame by default) */
  55934. get refreshRate(): number;
  55935. set refreshRate(value: number);
  55936. /**
  55937. * Gets the hosting scene
  55938. * @returns a Scene
  55939. */
  55940. getScene(): Scene;
  55941. /** Gets the internal CubeTexture used to render to */
  55942. get cubeTexture(): RenderTargetTexture;
  55943. /** Gets the list of meshes to render */
  55944. get renderList(): Nullable<AbstractMesh[]>;
  55945. /**
  55946. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55947. * @param mesh defines the mesh to attach to
  55948. */
  55949. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55950. /**
  55951. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55952. * @param renderingGroupId The rendering group id corresponding to its index
  55953. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55954. */
  55955. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55956. /**
  55957. * Clean all associated resources
  55958. */
  55959. dispose(): void;
  55960. /**
  55961. * Converts the reflection probe information to a readable string for debug purpose.
  55962. * @param fullDetails Supports for multiple levels of logging within scene loading
  55963. * @returns the human readable reflection probe info
  55964. */
  55965. toString(fullDetails?: boolean): string;
  55966. /**
  55967. * Get the class name of the relfection probe.
  55968. * @returns "ReflectionProbe"
  55969. */
  55970. getClassName(): string;
  55971. /**
  55972. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55973. * @returns The JSON representation of the texture
  55974. */
  55975. serialize(): any;
  55976. /**
  55977. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55978. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55979. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55980. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55981. * @returns The parsed reflection probe if successful
  55982. */
  55983. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55984. }
  55985. }
  55986. declare module BABYLON {
  55987. /** @hidden */
  55988. export var _BabylonLoaderRegistered: boolean;
  55989. /**
  55990. * Helps setting up some configuration for the babylon file loader.
  55991. */
  55992. export class BabylonFileLoaderConfiguration {
  55993. /**
  55994. * The loader does not allow injecting custom physix engine into the plugins.
  55995. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55996. * So you could set this variable to your engine import to make it work.
  55997. */
  55998. static LoaderInjectedPhysicsEngine: any;
  55999. }
  56000. }
  56001. declare module BABYLON {
  56002. /**
  56003. * The Physically based simple base material of BJS.
  56004. *
  56005. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56006. * It is used as the base class for both the specGloss and metalRough conventions.
  56007. */
  56008. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56009. /**
  56010. * Number of Simultaneous lights allowed on the material.
  56011. */
  56012. maxSimultaneousLights: number;
  56013. /**
  56014. * If sets to true, disables all the lights affecting the material.
  56015. */
  56016. disableLighting: boolean;
  56017. /**
  56018. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56019. */
  56020. environmentTexture: BaseTexture;
  56021. /**
  56022. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56023. */
  56024. invertNormalMapX: boolean;
  56025. /**
  56026. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56027. */
  56028. invertNormalMapY: boolean;
  56029. /**
  56030. * Normal map used in the model.
  56031. */
  56032. normalTexture: BaseTexture;
  56033. /**
  56034. * Emissivie color used to self-illuminate the model.
  56035. */
  56036. emissiveColor: Color3;
  56037. /**
  56038. * Emissivie texture used to self-illuminate the model.
  56039. */
  56040. emissiveTexture: BaseTexture;
  56041. /**
  56042. * Occlusion Channel Strenght.
  56043. */
  56044. occlusionStrength: number;
  56045. /**
  56046. * Occlusion Texture of the material (adding extra occlusion effects).
  56047. */
  56048. occlusionTexture: BaseTexture;
  56049. /**
  56050. * Defines the alpha limits in alpha test mode.
  56051. */
  56052. alphaCutOff: number;
  56053. /**
  56054. * Gets the current double sided mode.
  56055. */
  56056. get doubleSided(): boolean;
  56057. /**
  56058. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56059. */
  56060. set doubleSided(value: boolean);
  56061. /**
  56062. * Stores the pre-calculated light information of a mesh in a texture.
  56063. */
  56064. lightmapTexture: BaseTexture;
  56065. /**
  56066. * If true, the light map contains occlusion information instead of lighting info.
  56067. */
  56068. useLightmapAsShadowmap: boolean;
  56069. /**
  56070. * Instantiates a new PBRMaterial instance.
  56071. *
  56072. * @param name The material name
  56073. * @param scene The scene the material will be use in.
  56074. */
  56075. constructor(name: string, scene: Scene);
  56076. getClassName(): string;
  56077. }
  56078. }
  56079. declare module BABYLON {
  56080. /**
  56081. * The PBR material of BJS following the metal roughness convention.
  56082. *
  56083. * This fits to the PBR convention in the GLTF definition:
  56084. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56085. */
  56086. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56087. /**
  56088. * The base color has two different interpretations depending on the value of metalness.
  56089. * When the material is a metal, the base color is the specific measured reflectance value
  56090. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56091. * of the material.
  56092. */
  56093. baseColor: Color3;
  56094. /**
  56095. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56096. * well as opacity information in the alpha channel.
  56097. */
  56098. baseTexture: BaseTexture;
  56099. /**
  56100. * Specifies the metallic scalar value of the material.
  56101. * Can also be used to scale the metalness values of the metallic texture.
  56102. */
  56103. metallic: number;
  56104. /**
  56105. * Specifies the roughness scalar value of the material.
  56106. * Can also be used to scale the roughness values of the metallic texture.
  56107. */
  56108. roughness: number;
  56109. /**
  56110. * Texture containing both the metallic value in the B channel and the
  56111. * roughness value in the G channel to keep better precision.
  56112. */
  56113. metallicRoughnessTexture: BaseTexture;
  56114. /**
  56115. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56116. *
  56117. * @param name The material name
  56118. * @param scene The scene the material will be use in.
  56119. */
  56120. constructor(name: string, scene: Scene);
  56121. /**
  56122. * Return the currrent class name of the material.
  56123. */
  56124. getClassName(): string;
  56125. /**
  56126. * Makes a duplicate of the current material.
  56127. * @param name - name to use for the new material.
  56128. */
  56129. clone(name: string): PBRMetallicRoughnessMaterial;
  56130. /**
  56131. * Serialize the material to a parsable JSON object.
  56132. */
  56133. serialize(): any;
  56134. /**
  56135. * Parses a JSON object correponding to the serialize function.
  56136. */
  56137. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56138. }
  56139. }
  56140. declare module BABYLON {
  56141. /**
  56142. * The PBR material of BJS following the specular glossiness convention.
  56143. *
  56144. * This fits to the PBR convention in the GLTF definition:
  56145. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56146. */
  56147. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56148. /**
  56149. * Specifies the diffuse color of the material.
  56150. */
  56151. diffuseColor: Color3;
  56152. /**
  56153. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56154. * channel.
  56155. */
  56156. diffuseTexture: BaseTexture;
  56157. /**
  56158. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56159. */
  56160. specularColor: Color3;
  56161. /**
  56162. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56163. */
  56164. glossiness: number;
  56165. /**
  56166. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56167. */
  56168. specularGlossinessTexture: BaseTexture;
  56169. /**
  56170. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56171. *
  56172. * @param name The material name
  56173. * @param scene The scene the material will be use in.
  56174. */
  56175. constructor(name: string, scene: Scene);
  56176. /**
  56177. * Return the currrent class name of the material.
  56178. */
  56179. getClassName(): string;
  56180. /**
  56181. * Makes a duplicate of the current material.
  56182. * @param name - name to use for the new material.
  56183. */
  56184. clone(name: string): PBRSpecularGlossinessMaterial;
  56185. /**
  56186. * Serialize the material to a parsable JSON object.
  56187. */
  56188. serialize(): any;
  56189. /**
  56190. * Parses a JSON object correponding to the serialize function.
  56191. */
  56192. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56193. }
  56194. }
  56195. declare module BABYLON {
  56196. /**
  56197. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56198. * It can help converting any input color in a desired output one. This can then be used to create effects
  56199. * from sepia, black and white to sixties or futuristic rendering...
  56200. *
  56201. * The only supported format is currently 3dl.
  56202. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56203. */
  56204. export class ColorGradingTexture extends BaseTexture {
  56205. /**
  56206. * The current texture matrix. (will always be identity in color grading texture)
  56207. */
  56208. private _textureMatrix;
  56209. /**
  56210. * The texture URL.
  56211. */
  56212. url: string;
  56213. /**
  56214. * Empty line regex stored for GC.
  56215. */
  56216. private static _noneEmptyLineRegex;
  56217. private _engine;
  56218. /**
  56219. * Instantiates a ColorGradingTexture from the following parameters.
  56220. *
  56221. * @param url The location of the color gradind data (currently only supporting 3dl)
  56222. * @param scene The scene the texture will be used in
  56223. */
  56224. constructor(url: string, scene: Scene);
  56225. /**
  56226. * Returns the texture matrix used in most of the material.
  56227. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56228. */
  56229. getTextureMatrix(): Matrix;
  56230. /**
  56231. * Occurs when the file being loaded is a .3dl LUT file.
  56232. */
  56233. private load3dlTexture;
  56234. /**
  56235. * Starts the loading process of the texture.
  56236. */
  56237. private loadTexture;
  56238. /**
  56239. * Clones the color gradind texture.
  56240. */
  56241. clone(): ColorGradingTexture;
  56242. /**
  56243. * Called during delayed load for textures.
  56244. */
  56245. delayLoad(): void;
  56246. /**
  56247. * Parses a color grading texture serialized by Babylon.
  56248. * @param parsedTexture The texture information being parsedTexture
  56249. * @param scene The scene to load the texture in
  56250. * @param rootUrl The root url of the data assets to load
  56251. * @return A color gradind texture
  56252. */
  56253. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56254. /**
  56255. * Serializes the LUT texture to json format.
  56256. */
  56257. serialize(): any;
  56258. }
  56259. }
  56260. declare module BABYLON {
  56261. /**
  56262. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56263. */
  56264. export class EquiRectangularCubeTexture extends BaseTexture {
  56265. /** The six faces of the cube. */
  56266. private static _FacesMapping;
  56267. private _noMipmap;
  56268. private _onLoad;
  56269. private _onError;
  56270. /** The size of the cubemap. */
  56271. private _size;
  56272. /** The buffer of the image. */
  56273. private _buffer;
  56274. /** The width of the input image. */
  56275. private _width;
  56276. /** The height of the input image. */
  56277. private _height;
  56278. /** The URL to the image. */
  56279. url: string;
  56280. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56281. coordinatesMode: number;
  56282. /**
  56283. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56284. * @param url The location of the image
  56285. * @param scene The scene the texture will be used in
  56286. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56287. * @param noMipmap Forces to not generate the mipmap if true
  56288. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56289. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56290. * @param onLoad — defines a callback called when texture is loaded
  56291. * @param onError — defines a callback called if there is an error
  56292. */
  56293. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56294. /**
  56295. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56296. */
  56297. private loadImage;
  56298. /**
  56299. * Convert the image buffer into a cubemap and create a CubeTexture.
  56300. */
  56301. private loadTexture;
  56302. /**
  56303. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56304. * @param buffer The ArrayBuffer that should be converted.
  56305. * @returns The buffer as Float32Array.
  56306. */
  56307. private getFloat32ArrayFromArrayBuffer;
  56308. /**
  56309. * Get the current class name of the texture useful for serialization or dynamic coding.
  56310. * @returns "EquiRectangularCubeTexture"
  56311. */
  56312. getClassName(): string;
  56313. /**
  56314. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56315. * @returns A clone of the current EquiRectangularCubeTexture.
  56316. */
  56317. clone(): EquiRectangularCubeTexture;
  56318. }
  56319. }
  56320. declare module BABYLON {
  56321. /**
  56322. * Based on jsTGALoader - Javascript loader for TGA file
  56323. * By Vincent Thibault
  56324. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56325. */
  56326. export class TGATools {
  56327. private static _TYPE_INDEXED;
  56328. private static _TYPE_RGB;
  56329. private static _TYPE_GREY;
  56330. private static _TYPE_RLE_INDEXED;
  56331. private static _TYPE_RLE_RGB;
  56332. private static _TYPE_RLE_GREY;
  56333. private static _ORIGIN_MASK;
  56334. private static _ORIGIN_SHIFT;
  56335. private static _ORIGIN_BL;
  56336. private static _ORIGIN_BR;
  56337. private static _ORIGIN_UL;
  56338. private static _ORIGIN_UR;
  56339. /**
  56340. * Gets the header of a TGA file
  56341. * @param data defines the TGA data
  56342. * @returns the header
  56343. */
  56344. static GetTGAHeader(data: Uint8Array): any;
  56345. /**
  56346. * Uploads TGA content to a Babylon Texture
  56347. * @hidden
  56348. */
  56349. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56350. /** @hidden */
  56351. 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;
  56352. /** @hidden */
  56353. 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;
  56354. /** @hidden */
  56355. 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;
  56356. /** @hidden */
  56357. 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;
  56358. /** @hidden */
  56359. 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;
  56360. /** @hidden */
  56361. 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;
  56362. }
  56363. }
  56364. declare module BABYLON {
  56365. /**
  56366. * Implementation of the TGA Texture Loader.
  56367. * @hidden
  56368. */
  56369. export class _TGATextureLoader implements IInternalTextureLoader {
  56370. /**
  56371. * Defines wether the loader supports cascade loading the different faces.
  56372. */
  56373. readonly supportCascades: boolean;
  56374. /**
  56375. * This returns if the loader support the current file information.
  56376. * @param extension defines the file extension of the file being loaded
  56377. * @returns true if the loader can load the specified file
  56378. */
  56379. canLoad(extension: string): boolean;
  56380. /**
  56381. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56382. * @param data contains the texture data
  56383. * @param texture defines the BabylonJS internal texture
  56384. * @param createPolynomials will be true if polynomials have been requested
  56385. * @param onLoad defines the callback to trigger once the texture is ready
  56386. * @param onError defines the callback to trigger in case of error
  56387. */
  56388. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56389. /**
  56390. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56391. * @param data contains the texture data
  56392. * @param texture defines the BabylonJS internal texture
  56393. * @param callback defines the method to call once ready to upload
  56394. */
  56395. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56396. }
  56397. }
  56398. declare module BABYLON {
  56399. /**
  56400. * Info about the .basis files
  56401. */
  56402. class BasisFileInfo {
  56403. /**
  56404. * If the file has alpha
  56405. */
  56406. hasAlpha: boolean;
  56407. /**
  56408. * Info about each image of the basis file
  56409. */
  56410. images: Array<{
  56411. levels: Array<{
  56412. width: number;
  56413. height: number;
  56414. transcodedPixels: ArrayBufferView;
  56415. }>;
  56416. }>;
  56417. }
  56418. /**
  56419. * Result of transcoding a basis file
  56420. */
  56421. class TranscodeResult {
  56422. /**
  56423. * Info about the .basis file
  56424. */
  56425. fileInfo: BasisFileInfo;
  56426. /**
  56427. * Format to use when loading the file
  56428. */
  56429. format: number;
  56430. }
  56431. /**
  56432. * Configuration options for the Basis transcoder
  56433. */
  56434. export class BasisTranscodeConfiguration {
  56435. /**
  56436. * Supported compression formats used to determine the supported output format of the transcoder
  56437. */
  56438. supportedCompressionFormats?: {
  56439. /**
  56440. * etc1 compression format
  56441. */
  56442. etc1?: boolean;
  56443. /**
  56444. * s3tc compression format
  56445. */
  56446. s3tc?: boolean;
  56447. /**
  56448. * pvrtc compression format
  56449. */
  56450. pvrtc?: boolean;
  56451. /**
  56452. * etc2 compression format
  56453. */
  56454. etc2?: boolean;
  56455. };
  56456. /**
  56457. * If mipmap levels should be loaded for transcoded images (Default: true)
  56458. */
  56459. loadMipmapLevels?: boolean;
  56460. /**
  56461. * Index of a single image to load (Default: all images)
  56462. */
  56463. loadSingleImage?: number;
  56464. }
  56465. /**
  56466. * Used to load .Basis files
  56467. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56468. */
  56469. export class BasisTools {
  56470. private static _IgnoreSupportedFormats;
  56471. /**
  56472. * URL to use when loading the basis transcoder
  56473. */
  56474. static JSModuleURL: string;
  56475. /**
  56476. * URL to use when loading the wasm module for the transcoder
  56477. */
  56478. static WasmModuleURL: string;
  56479. /**
  56480. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56481. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56482. * @returns internal format corresponding to the Basis format
  56483. */
  56484. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56485. private static _WorkerPromise;
  56486. private static _Worker;
  56487. private static _actionId;
  56488. private static _CreateWorkerAsync;
  56489. /**
  56490. * Transcodes a loaded image file to compressed pixel data
  56491. * @param data image data to transcode
  56492. * @param config configuration options for the transcoding
  56493. * @returns a promise resulting in the transcoded image
  56494. */
  56495. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56496. /**
  56497. * Loads a texture from the transcode result
  56498. * @param texture texture load to
  56499. * @param transcodeResult the result of transcoding the basis file to load from
  56500. */
  56501. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56502. }
  56503. }
  56504. declare module BABYLON {
  56505. /**
  56506. * Loader for .basis file format
  56507. */
  56508. export class _BasisTextureLoader implements IInternalTextureLoader {
  56509. /**
  56510. * Defines whether the loader supports cascade loading the different faces.
  56511. */
  56512. readonly supportCascades: boolean;
  56513. /**
  56514. * This returns if the loader support the current file information.
  56515. * @param extension defines the file extension of the file being loaded
  56516. * @returns true if the loader can load the specified file
  56517. */
  56518. canLoad(extension: string): boolean;
  56519. /**
  56520. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56521. * @param data contains the texture data
  56522. * @param texture defines the BabylonJS internal texture
  56523. * @param createPolynomials will be true if polynomials have been requested
  56524. * @param onLoad defines the callback to trigger once the texture is ready
  56525. * @param onError defines the callback to trigger in case of error
  56526. */
  56527. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56528. /**
  56529. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56530. * @param data contains the texture data
  56531. * @param texture defines the BabylonJS internal texture
  56532. * @param callback defines the method to call once ready to upload
  56533. */
  56534. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56535. }
  56536. }
  56537. declare module BABYLON {
  56538. /**
  56539. * 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.
  56540. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56541. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56542. */
  56543. export class CustomProceduralTexture extends ProceduralTexture {
  56544. private _animate;
  56545. private _time;
  56546. private _config;
  56547. private _texturePath;
  56548. /**
  56549. * Instantiates a new Custom Procedural Texture.
  56550. * 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.
  56551. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56552. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56553. * @param name Define the name of the texture
  56554. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56555. * @param size Define the size of the texture to create
  56556. * @param scene Define the scene the texture belongs to
  56557. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56558. * @param generateMipMaps Define if the texture should creates mip maps or not
  56559. */
  56560. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56561. private _loadJson;
  56562. /**
  56563. * Is the texture ready to be used ? (rendered at least once)
  56564. * @returns true if ready, otherwise, false.
  56565. */
  56566. isReady(): boolean;
  56567. /**
  56568. * Render the texture to its associated render target.
  56569. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56570. */
  56571. render(useCameraPostProcess?: boolean): void;
  56572. /**
  56573. * Update the list of dependant textures samplers in the shader.
  56574. */
  56575. updateTextures(): void;
  56576. /**
  56577. * Update the uniform values of the procedural texture in the shader.
  56578. */
  56579. updateShaderUniforms(): void;
  56580. /**
  56581. * Define if the texture animates or not.
  56582. */
  56583. get animate(): boolean;
  56584. set animate(value: boolean);
  56585. }
  56586. }
  56587. declare module BABYLON {
  56588. /** @hidden */
  56589. export var noisePixelShader: {
  56590. name: string;
  56591. shader: string;
  56592. };
  56593. }
  56594. declare module BABYLON {
  56595. /**
  56596. * Class used to generate noise procedural textures
  56597. */
  56598. export class NoiseProceduralTexture extends ProceduralTexture {
  56599. private _time;
  56600. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56601. brightness: number;
  56602. /** Defines the number of octaves to process */
  56603. octaves: number;
  56604. /** Defines the level of persistence (0.8 by default) */
  56605. persistence: number;
  56606. /** Gets or sets animation speed factor (default is 1) */
  56607. animationSpeedFactor: number;
  56608. /**
  56609. * Creates a new NoiseProceduralTexture
  56610. * @param name defines the name fo the texture
  56611. * @param size defines the size of the texture (default is 256)
  56612. * @param scene defines the hosting scene
  56613. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56614. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56615. */
  56616. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56617. private _updateShaderUniforms;
  56618. protected _getDefines(): string;
  56619. /** Generate the current state of the procedural texture */
  56620. render(useCameraPostProcess?: boolean): void;
  56621. /**
  56622. * Serializes this noise procedural texture
  56623. * @returns a serialized noise procedural texture object
  56624. */
  56625. serialize(): any;
  56626. /**
  56627. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56628. * @param parsedTexture defines parsed texture data
  56629. * @param scene defines the current scene
  56630. * @param rootUrl defines the root URL containing noise procedural texture information
  56631. * @returns a parsed NoiseProceduralTexture
  56632. */
  56633. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56634. }
  56635. }
  56636. declare module BABYLON {
  56637. /**
  56638. * Raw cube texture where the raw buffers are passed in
  56639. */
  56640. export class RawCubeTexture extends CubeTexture {
  56641. /**
  56642. * Creates a cube texture where the raw buffers are passed in.
  56643. * @param scene defines the scene the texture is attached to
  56644. * @param data defines the array of data to use to create each face
  56645. * @param size defines the size of the textures
  56646. * @param format defines the format of the data
  56647. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56648. * @param generateMipMaps defines if the engine should generate the mip levels
  56649. * @param invertY defines if data must be stored with Y axis inverted
  56650. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56651. * @param compression defines the compression used (null by default)
  56652. */
  56653. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56654. /**
  56655. * Updates the raw cube texture.
  56656. * @param data defines the data to store
  56657. * @param format defines the data format
  56658. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56659. * @param invertY defines if data must be stored with Y axis inverted
  56660. * @param compression defines the compression used (null by default)
  56661. * @param level defines which level of the texture to update
  56662. */
  56663. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56664. /**
  56665. * Updates a raw cube texture with RGBD encoded data.
  56666. * @param data defines the array of data [mipmap][face] to use to create each face
  56667. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56668. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56669. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56670. * @returns a promsie that resolves when the operation is complete
  56671. */
  56672. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56673. /**
  56674. * Clones the raw cube texture.
  56675. * @return a new cube texture
  56676. */
  56677. clone(): CubeTexture;
  56678. /** @hidden */
  56679. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. /**
  56684. * Class used to store 3D textures containing user data
  56685. */
  56686. export class RawTexture3D extends Texture {
  56687. /** Gets or sets the texture format to use */
  56688. format: number;
  56689. private _engine;
  56690. /**
  56691. * Create a new RawTexture3D
  56692. * @param data defines the data of the texture
  56693. * @param width defines the width of the texture
  56694. * @param height defines the height of the texture
  56695. * @param depth defines the depth of the texture
  56696. * @param format defines the texture format to use
  56697. * @param scene defines the hosting scene
  56698. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56699. * @param invertY defines if texture must be stored with Y axis inverted
  56700. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56701. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56702. */
  56703. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56704. /** Gets or sets the texture format to use */
  56705. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56706. /**
  56707. * Update the texture with new data
  56708. * @param data defines the data to store in the texture
  56709. */
  56710. update(data: ArrayBufferView): void;
  56711. }
  56712. }
  56713. declare module BABYLON {
  56714. /**
  56715. * Class used to store 2D array textures containing user data
  56716. */
  56717. export class RawTexture2DArray extends Texture {
  56718. /** Gets or sets the texture format to use */
  56719. format: number;
  56720. private _engine;
  56721. /**
  56722. * Create a new RawTexture2DArray
  56723. * @param data defines the data of the texture
  56724. * @param width defines the width of the texture
  56725. * @param height defines the height of the texture
  56726. * @param depth defines the number of layers of the texture
  56727. * @param format defines the texture format to use
  56728. * @param scene defines the hosting scene
  56729. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56730. * @param invertY defines if texture must be stored with Y axis inverted
  56731. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56732. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56733. */
  56734. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56735. /** Gets or sets the texture format to use */
  56736. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56737. /**
  56738. * Update the texture with new data
  56739. * @param data defines the data to store in the texture
  56740. */
  56741. update(data: ArrayBufferView): void;
  56742. }
  56743. }
  56744. declare module BABYLON {
  56745. /**
  56746. * Creates a refraction texture used by refraction channel of the standard material.
  56747. * It is like a mirror but to see through a material.
  56748. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56749. */
  56750. export class RefractionTexture extends RenderTargetTexture {
  56751. /**
  56752. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56753. * 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.
  56754. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56755. */
  56756. refractionPlane: Plane;
  56757. /**
  56758. * Define how deep under the surface we should see.
  56759. */
  56760. depth: number;
  56761. /**
  56762. * Creates a refraction texture used by refraction channel of the standard material.
  56763. * It is like a mirror but to see through a material.
  56764. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56765. * @param name Define the texture name
  56766. * @param size Define the size of the underlying texture
  56767. * @param scene Define the scene the refraction belongs to
  56768. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56769. */
  56770. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56771. /**
  56772. * Clone the refraction texture.
  56773. * @returns the cloned texture
  56774. */
  56775. clone(): RefractionTexture;
  56776. /**
  56777. * Serialize the texture to a JSON representation you could use in Parse later on
  56778. * @returns the serialized JSON representation
  56779. */
  56780. serialize(): any;
  56781. }
  56782. }
  56783. declare module BABYLON {
  56784. /**
  56785. * Defines the options related to the creation of an HtmlElementTexture
  56786. */
  56787. export interface IHtmlElementTextureOptions {
  56788. /**
  56789. * Defines wether mip maps should be created or not.
  56790. */
  56791. generateMipMaps?: boolean;
  56792. /**
  56793. * Defines the sampling mode of the texture.
  56794. */
  56795. samplingMode?: number;
  56796. /**
  56797. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56798. */
  56799. engine: Nullable<ThinEngine>;
  56800. /**
  56801. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56802. */
  56803. scene: Nullable<Scene>;
  56804. }
  56805. /**
  56806. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56807. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56808. * is automatically managed.
  56809. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56810. * in your application.
  56811. *
  56812. * As the update is not automatic, you need to call them manually.
  56813. */
  56814. export class HtmlElementTexture extends BaseTexture {
  56815. /**
  56816. * The texture URL.
  56817. */
  56818. element: HTMLVideoElement | HTMLCanvasElement;
  56819. private static readonly DefaultOptions;
  56820. private _textureMatrix;
  56821. private _engine;
  56822. private _isVideo;
  56823. private _generateMipMaps;
  56824. private _samplingMode;
  56825. /**
  56826. * Instantiates a HtmlElementTexture from the following parameters.
  56827. *
  56828. * @param name Defines the name of the texture
  56829. * @param element Defines the video or canvas the texture is filled with
  56830. * @param options Defines the other none mandatory texture creation options
  56831. */
  56832. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56833. private _createInternalTexture;
  56834. /**
  56835. * Returns the texture matrix used in most of the material.
  56836. */
  56837. getTextureMatrix(): Matrix;
  56838. /**
  56839. * Updates the content of the texture.
  56840. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56841. */
  56842. update(invertY?: Nullable<boolean>): void;
  56843. }
  56844. }
  56845. declare module BABYLON {
  56846. /**
  56847. * Defines the basic options interface of a TexturePacker Frame
  56848. */
  56849. export interface ITexturePackerFrame {
  56850. /**
  56851. * The frame ID
  56852. */
  56853. id: number;
  56854. /**
  56855. * The frames Scale
  56856. */
  56857. scale: Vector2;
  56858. /**
  56859. * The Frames offset
  56860. */
  56861. offset: Vector2;
  56862. }
  56863. /**
  56864. * This is a support class for frame Data on texture packer sets.
  56865. */
  56866. export class TexturePackerFrame implements ITexturePackerFrame {
  56867. /**
  56868. * The frame ID
  56869. */
  56870. id: number;
  56871. /**
  56872. * The frames Scale
  56873. */
  56874. scale: Vector2;
  56875. /**
  56876. * The Frames offset
  56877. */
  56878. offset: Vector2;
  56879. /**
  56880. * Initializes a texture package frame.
  56881. * @param id The numerical frame identifier
  56882. * @param scale Scalar Vector2 for UV frame
  56883. * @param offset Vector2 for the frame position in UV units.
  56884. * @returns TexturePackerFrame
  56885. */
  56886. constructor(id: number, scale: Vector2, offset: Vector2);
  56887. }
  56888. }
  56889. declare module BABYLON {
  56890. /**
  56891. * Defines the basic options interface of a TexturePacker
  56892. */
  56893. export interface ITexturePackerOptions {
  56894. /**
  56895. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56896. */
  56897. map?: string[];
  56898. /**
  56899. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56900. */
  56901. uvsIn?: string;
  56902. /**
  56903. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56904. */
  56905. uvsOut?: string;
  56906. /**
  56907. * number representing the layout style. Defaults to LAYOUT_STRIP
  56908. */
  56909. layout?: number;
  56910. /**
  56911. * number of columns if using custom column count layout(2). This defaults to 4.
  56912. */
  56913. colnum?: number;
  56914. /**
  56915. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56916. */
  56917. updateInputMeshes?: boolean;
  56918. /**
  56919. * boolean flag to dispose all the source textures. Defaults to true.
  56920. */
  56921. disposeSources?: boolean;
  56922. /**
  56923. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56924. */
  56925. fillBlanks?: boolean;
  56926. /**
  56927. * string value representing the context fill style color. Defaults to 'black'.
  56928. */
  56929. customFillColor?: string;
  56930. /**
  56931. * Width and Height Value of each Frame in the TexturePacker Sets
  56932. */
  56933. frameSize?: number;
  56934. /**
  56935. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56936. */
  56937. paddingRatio?: number;
  56938. /**
  56939. * Number that declares the fill method for the padding gutter.
  56940. */
  56941. paddingMode?: number;
  56942. /**
  56943. * If in SUBUV_COLOR padding mode what color to use.
  56944. */
  56945. paddingColor?: Color3 | Color4;
  56946. }
  56947. /**
  56948. * Defines the basic interface of a TexturePacker JSON File
  56949. */
  56950. export interface ITexturePackerJSON {
  56951. /**
  56952. * The frame ID
  56953. */
  56954. name: string;
  56955. /**
  56956. * The base64 channel data
  56957. */
  56958. sets: any;
  56959. /**
  56960. * The options of the Packer
  56961. */
  56962. options: ITexturePackerOptions;
  56963. /**
  56964. * The frame data of the Packer
  56965. */
  56966. frames: Array<number>;
  56967. }
  56968. /**
  56969. * This is a support class that generates a series of packed texture sets.
  56970. * @see https://doc.babylonjs.com/babylon101/materials
  56971. */
  56972. export class TexturePacker {
  56973. /** Packer Layout Constant 0 */
  56974. static readonly LAYOUT_STRIP: number;
  56975. /** Packer Layout Constant 1 */
  56976. static readonly LAYOUT_POWER2: number;
  56977. /** Packer Layout Constant 2 */
  56978. static readonly LAYOUT_COLNUM: number;
  56979. /** Packer Layout Constant 0 */
  56980. static readonly SUBUV_WRAP: number;
  56981. /** Packer Layout Constant 1 */
  56982. static readonly SUBUV_EXTEND: number;
  56983. /** Packer Layout Constant 2 */
  56984. static readonly SUBUV_COLOR: number;
  56985. /** The Name of the Texture Package */
  56986. name: string;
  56987. /** The scene scope of the TexturePacker */
  56988. scene: Scene;
  56989. /** The Meshes to target */
  56990. meshes: AbstractMesh[];
  56991. /** Arguments passed with the Constructor */
  56992. options: ITexturePackerOptions;
  56993. /** The promise that is started upon initialization */
  56994. promise: Nullable<Promise<TexturePacker | string>>;
  56995. /** The Container object for the channel sets that are generated */
  56996. sets: object;
  56997. /** The Container array for the frames that are generated */
  56998. frames: TexturePackerFrame[];
  56999. /** The expected number of textures the system is parsing. */
  57000. private _expecting;
  57001. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57002. private _paddingValue;
  57003. /**
  57004. * Initializes a texture package series from an array of meshes or a single mesh.
  57005. * @param name The name of the package
  57006. * @param meshes The target meshes to compose the package from
  57007. * @param options The arguments that texture packer should follow while building.
  57008. * @param scene The scene which the textures are scoped to.
  57009. * @returns TexturePacker
  57010. */
  57011. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57012. /**
  57013. * Starts the package process
  57014. * @param resolve The promises resolution function
  57015. * @returns TexturePacker
  57016. */
  57017. private _createFrames;
  57018. /**
  57019. * Calculates the Size of the Channel Sets
  57020. * @returns Vector2
  57021. */
  57022. private _calculateSize;
  57023. /**
  57024. * Calculates the UV data for the frames.
  57025. * @param baseSize the base frameSize
  57026. * @param padding the base frame padding
  57027. * @param dtSize size of the Dynamic Texture for that channel
  57028. * @param dtUnits is 1/dtSize
  57029. * @param update flag to update the input meshes
  57030. */
  57031. private _calculateMeshUVFrames;
  57032. /**
  57033. * Calculates the frames Offset.
  57034. * @param index of the frame
  57035. * @returns Vector2
  57036. */
  57037. private _getFrameOffset;
  57038. /**
  57039. * Updates a Mesh to the frame data
  57040. * @param mesh that is the target
  57041. * @param frameID or the frame index
  57042. */
  57043. private _updateMeshUV;
  57044. /**
  57045. * Updates a Meshes materials to use the texture packer channels
  57046. * @param m is the mesh to target
  57047. * @param force all channels on the packer to be set.
  57048. */
  57049. private _updateTextureReferences;
  57050. /**
  57051. * Public method to set a Mesh to a frame
  57052. * @param m that is the target
  57053. * @param frameID or the frame index
  57054. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57055. */
  57056. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57057. /**
  57058. * Starts the async promise to compile the texture packer.
  57059. * @returns Promise<void>
  57060. */
  57061. processAsync(): Promise<void>;
  57062. /**
  57063. * Disposes all textures associated with this packer
  57064. */
  57065. dispose(): void;
  57066. /**
  57067. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57068. * @param imageType is the image type to use.
  57069. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57070. */
  57071. download(imageType?: string, quality?: number): void;
  57072. /**
  57073. * Public method to load a texturePacker JSON file.
  57074. * @param data of the JSON file in string format.
  57075. */
  57076. updateFromJSON(data: string): void;
  57077. }
  57078. }
  57079. declare module BABYLON {
  57080. /**
  57081. * Enum used to define the target of a block
  57082. */
  57083. export enum NodeMaterialBlockTargets {
  57084. /** Vertex shader */
  57085. Vertex = 1,
  57086. /** Fragment shader */
  57087. Fragment = 2,
  57088. /** Neutral */
  57089. Neutral = 4,
  57090. /** Vertex and Fragment */
  57091. VertexAndFragment = 3
  57092. }
  57093. }
  57094. declare module BABYLON {
  57095. /**
  57096. * Defines the kind of connection point for node based material
  57097. */
  57098. export enum NodeMaterialBlockConnectionPointTypes {
  57099. /** Float */
  57100. Float = 1,
  57101. /** Int */
  57102. Int = 2,
  57103. /** Vector2 */
  57104. Vector2 = 4,
  57105. /** Vector3 */
  57106. Vector3 = 8,
  57107. /** Vector4 */
  57108. Vector4 = 16,
  57109. /** Color3 */
  57110. Color3 = 32,
  57111. /** Color4 */
  57112. Color4 = 64,
  57113. /** Matrix */
  57114. Matrix = 128,
  57115. /** Detect type based on connection */
  57116. AutoDetect = 1024,
  57117. /** Output type that will be defined by input type */
  57118. BasedOnInput = 2048
  57119. }
  57120. }
  57121. declare module BABYLON {
  57122. /**
  57123. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57124. */
  57125. export enum NodeMaterialBlockConnectionPointMode {
  57126. /** Value is an uniform */
  57127. Uniform = 0,
  57128. /** Value is a mesh attribute */
  57129. Attribute = 1,
  57130. /** Value is a varying between vertex and fragment shaders */
  57131. Varying = 2,
  57132. /** Mode is undefined */
  57133. Undefined = 3
  57134. }
  57135. }
  57136. declare module BABYLON {
  57137. /**
  57138. * Enum used to define system values e.g. values automatically provided by the system
  57139. */
  57140. export enum NodeMaterialSystemValues {
  57141. /** World */
  57142. World = 1,
  57143. /** View */
  57144. View = 2,
  57145. /** Projection */
  57146. Projection = 3,
  57147. /** ViewProjection */
  57148. ViewProjection = 4,
  57149. /** WorldView */
  57150. WorldView = 5,
  57151. /** WorldViewProjection */
  57152. WorldViewProjection = 6,
  57153. /** CameraPosition */
  57154. CameraPosition = 7,
  57155. /** Fog Color */
  57156. FogColor = 8,
  57157. /** Delta time */
  57158. DeltaTime = 9
  57159. }
  57160. }
  57161. declare module BABYLON {
  57162. /**
  57163. * Root class for all node material optimizers
  57164. */
  57165. export class NodeMaterialOptimizer {
  57166. /**
  57167. * Function used to optimize a NodeMaterial graph
  57168. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57169. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57170. */
  57171. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57172. }
  57173. }
  57174. declare module BABYLON {
  57175. /**
  57176. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57177. */
  57178. export class TransformBlock extends NodeMaterialBlock {
  57179. /**
  57180. * Defines the value to use to complement W value to transform it to a Vector4
  57181. */
  57182. complementW: number;
  57183. /**
  57184. * Defines the value to use to complement z value to transform it to a Vector4
  57185. */
  57186. complementZ: number;
  57187. /**
  57188. * Creates a new TransformBlock
  57189. * @param name defines the block name
  57190. */
  57191. constructor(name: string);
  57192. /**
  57193. * Gets the current class name
  57194. * @returns the class name
  57195. */
  57196. getClassName(): string;
  57197. /**
  57198. * Gets the vector input
  57199. */
  57200. get vector(): NodeMaterialConnectionPoint;
  57201. /**
  57202. * Gets the output component
  57203. */
  57204. get output(): NodeMaterialConnectionPoint;
  57205. /**
  57206. * Gets the xyz output component
  57207. */
  57208. get xyz(): NodeMaterialConnectionPoint;
  57209. /**
  57210. * Gets the matrix transform input
  57211. */
  57212. get transform(): NodeMaterialConnectionPoint;
  57213. protected _buildBlock(state: NodeMaterialBuildState): this;
  57214. serialize(): any;
  57215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57216. protected _dumpPropertiesCode(): string;
  57217. }
  57218. }
  57219. declare module BABYLON {
  57220. /**
  57221. * Block used to output the vertex position
  57222. */
  57223. export class VertexOutputBlock extends NodeMaterialBlock {
  57224. /**
  57225. * Creates a new VertexOutputBlock
  57226. * @param name defines the block name
  57227. */
  57228. constructor(name: string);
  57229. /**
  57230. * Gets the current class name
  57231. * @returns the class name
  57232. */
  57233. getClassName(): string;
  57234. /**
  57235. * Gets the vector input component
  57236. */
  57237. get vector(): NodeMaterialConnectionPoint;
  57238. protected _buildBlock(state: NodeMaterialBuildState): this;
  57239. }
  57240. }
  57241. declare module BABYLON {
  57242. /**
  57243. * Block used to output the final color
  57244. */
  57245. export class FragmentOutputBlock extends NodeMaterialBlock {
  57246. /**
  57247. * Create a new FragmentOutputBlock
  57248. * @param name defines the block name
  57249. */
  57250. constructor(name: string);
  57251. /**
  57252. * Gets the current class name
  57253. * @returns the class name
  57254. */
  57255. getClassName(): string;
  57256. /**
  57257. * Gets the rgba input component
  57258. */
  57259. get rgba(): NodeMaterialConnectionPoint;
  57260. /**
  57261. * Gets the rgb input component
  57262. */
  57263. get rgb(): NodeMaterialConnectionPoint;
  57264. /**
  57265. * Gets the a input component
  57266. */
  57267. get a(): NodeMaterialConnectionPoint;
  57268. protected _buildBlock(state: NodeMaterialBuildState): this;
  57269. }
  57270. }
  57271. declare module BABYLON {
  57272. /**
  57273. * Block used to read a reflection texture from a sampler
  57274. */
  57275. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57276. private _define3DName;
  57277. private _defineCubicName;
  57278. private _defineExplicitName;
  57279. private _defineProjectionName;
  57280. private _defineLocalCubicName;
  57281. private _defineSphericalName;
  57282. private _definePlanarName;
  57283. private _defineEquirectangularName;
  57284. private _defineMirroredEquirectangularFixedName;
  57285. private _defineEquirectangularFixedName;
  57286. private _defineSkyboxName;
  57287. private _cubeSamplerName;
  57288. private _2DSamplerName;
  57289. private _positionUVWName;
  57290. private _directionWName;
  57291. private _reflectionCoordsName;
  57292. private _reflection2DCoordsName;
  57293. private _reflectionColorName;
  57294. private _reflectionMatrixName;
  57295. /**
  57296. * Gets or sets the texture associated with the node
  57297. */
  57298. texture: Nullable<BaseTexture>;
  57299. /**
  57300. * Create a new TextureBlock
  57301. * @param name defines the block name
  57302. */
  57303. constructor(name: string);
  57304. /**
  57305. * Gets the current class name
  57306. * @returns the class name
  57307. */
  57308. getClassName(): string;
  57309. /**
  57310. * Gets the world position input component
  57311. */
  57312. get position(): NodeMaterialConnectionPoint;
  57313. /**
  57314. * Gets the world position input component
  57315. */
  57316. get worldPosition(): NodeMaterialConnectionPoint;
  57317. /**
  57318. * Gets the world normal input component
  57319. */
  57320. get worldNormal(): NodeMaterialConnectionPoint;
  57321. /**
  57322. * Gets the world input component
  57323. */
  57324. get world(): NodeMaterialConnectionPoint;
  57325. /**
  57326. * Gets the camera (or eye) position component
  57327. */
  57328. get cameraPosition(): NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the view input component
  57331. */
  57332. get view(): NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the rgb output component
  57335. */
  57336. get rgb(): NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the r output component
  57339. */
  57340. get r(): NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the g output component
  57343. */
  57344. get g(): NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the b output component
  57347. */
  57348. get b(): NodeMaterialConnectionPoint;
  57349. autoConfigure(material: NodeMaterial): void;
  57350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57351. isReady(): boolean;
  57352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57353. private _injectVertexCode;
  57354. private _writeOutput;
  57355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57356. protected _dumpPropertiesCode(): string;
  57357. serialize(): any;
  57358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57359. }
  57360. }
  57361. declare module BABYLON {
  57362. /**
  57363. * Interface used to configure the node material editor
  57364. */
  57365. export interface INodeMaterialEditorOptions {
  57366. /** Define the URl to load node editor script */
  57367. editorURL?: string;
  57368. }
  57369. /** @hidden */
  57370. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57371. NORMAL: boolean;
  57372. TANGENT: boolean;
  57373. UV1: boolean;
  57374. /** BONES */
  57375. NUM_BONE_INFLUENCERS: number;
  57376. BonesPerMesh: number;
  57377. BONETEXTURE: boolean;
  57378. /** MORPH TARGETS */
  57379. MORPHTARGETS: boolean;
  57380. MORPHTARGETS_NORMAL: boolean;
  57381. MORPHTARGETS_TANGENT: boolean;
  57382. MORPHTARGETS_UV: boolean;
  57383. NUM_MORPH_INFLUENCERS: number;
  57384. /** IMAGE PROCESSING */
  57385. IMAGEPROCESSING: boolean;
  57386. VIGNETTE: boolean;
  57387. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57388. VIGNETTEBLENDMODEOPAQUE: boolean;
  57389. TONEMAPPING: boolean;
  57390. TONEMAPPING_ACES: boolean;
  57391. CONTRAST: boolean;
  57392. EXPOSURE: boolean;
  57393. COLORCURVES: boolean;
  57394. COLORGRADING: boolean;
  57395. COLORGRADING3D: boolean;
  57396. SAMPLER3DGREENDEPTH: boolean;
  57397. SAMPLER3DBGRMAP: boolean;
  57398. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57399. /** MISC. */
  57400. BUMPDIRECTUV: number;
  57401. constructor();
  57402. setValue(name: string, value: boolean): void;
  57403. }
  57404. /**
  57405. * Class used to configure NodeMaterial
  57406. */
  57407. export interface INodeMaterialOptions {
  57408. /**
  57409. * Defines if blocks should emit comments
  57410. */
  57411. emitComments: boolean;
  57412. }
  57413. /**
  57414. * Class used to create a node based material built by assembling shader blocks
  57415. */
  57416. export class NodeMaterial extends PushMaterial {
  57417. private static _BuildIdGenerator;
  57418. private _options;
  57419. private _vertexCompilationState;
  57420. private _fragmentCompilationState;
  57421. private _sharedData;
  57422. private _buildId;
  57423. private _buildWasSuccessful;
  57424. private _cachedWorldViewMatrix;
  57425. private _cachedWorldViewProjectionMatrix;
  57426. private _optimizers;
  57427. private _animationFrame;
  57428. /** Define the Url to load node editor script */
  57429. static EditorURL: string;
  57430. /** Define the Url to load snippets */
  57431. static SnippetUrl: string;
  57432. private BJSNODEMATERIALEDITOR;
  57433. /** Get the inspector from bundle or global */
  57434. private _getGlobalNodeMaterialEditor;
  57435. /**
  57436. * Gets or sets data used by visual editor
  57437. * @see https://nme.babylonjs.com
  57438. */
  57439. editorData: any;
  57440. /**
  57441. * 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)
  57442. */
  57443. ignoreAlpha: boolean;
  57444. /**
  57445. * Defines the maximum number of lights that can be used in the material
  57446. */
  57447. maxSimultaneousLights: number;
  57448. /**
  57449. * Observable raised when the material is built
  57450. */
  57451. onBuildObservable: Observable<NodeMaterial>;
  57452. /**
  57453. * Gets or sets the root nodes of the material vertex shader
  57454. */
  57455. _vertexOutputNodes: NodeMaterialBlock[];
  57456. /**
  57457. * Gets or sets the root nodes of the material fragment (pixel) shader
  57458. */
  57459. _fragmentOutputNodes: NodeMaterialBlock[];
  57460. /** Gets or sets options to control the node material overall behavior */
  57461. get options(): INodeMaterialOptions;
  57462. set options(options: INodeMaterialOptions);
  57463. /**
  57464. * Default configuration related to image processing available in the standard Material.
  57465. */
  57466. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57467. /**
  57468. * Gets the image processing configuration used either in this material.
  57469. */
  57470. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57471. /**
  57472. * Sets the Default image processing configuration used either in the this material.
  57473. *
  57474. * If sets to null, the scene one is in use.
  57475. */
  57476. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57477. /**
  57478. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57479. */
  57480. attachedBlocks: NodeMaterialBlock[];
  57481. /**
  57482. * Create a new node based material
  57483. * @param name defines the material name
  57484. * @param scene defines the hosting scene
  57485. * @param options defines creation option
  57486. */
  57487. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57488. /**
  57489. * Gets the current class name of the material e.g. "NodeMaterial"
  57490. * @returns the class name
  57491. */
  57492. getClassName(): string;
  57493. /**
  57494. * Keep track of the image processing observer to allow dispose and replace.
  57495. */
  57496. private _imageProcessingObserver;
  57497. /**
  57498. * Attaches a new image processing configuration to the Standard Material.
  57499. * @param configuration
  57500. */
  57501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57502. /**
  57503. * Get a block by its name
  57504. * @param name defines the name of the block to retrieve
  57505. * @returns the required block or null if not found
  57506. */
  57507. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57508. /**
  57509. * Get a block by its name
  57510. * @param predicate defines the predicate used to find the good candidate
  57511. * @returns the required block or null if not found
  57512. */
  57513. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57514. /**
  57515. * Get an input block by its name
  57516. * @param predicate defines the predicate used to find the good candidate
  57517. * @returns the required input block or null if not found
  57518. */
  57519. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57520. /**
  57521. * Gets the list of input blocks attached to this material
  57522. * @returns an array of InputBlocks
  57523. */
  57524. getInputBlocks(): InputBlock[];
  57525. /**
  57526. * Adds a new optimizer to the list of optimizers
  57527. * @param optimizer defines the optimizers to add
  57528. * @returns the current material
  57529. */
  57530. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57531. /**
  57532. * Remove an optimizer from the list of optimizers
  57533. * @param optimizer defines the optimizers to remove
  57534. * @returns the current material
  57535. */
  57536. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57537. /**
  57538. * Add a new block to the list of output nodes
  57539. * @param node defines the node to add
  57540. * @returns the current material
  57541. */
  57542. addOutputNode(node: NodeMaterialBlock): this;
  57543. /**
  57544. * Remove a block from the list of root nodes
  57545. * @param node defines the node to remove
  57546. * @returns the current material
  57547. */
  57548. removeOutputNode(node: NodeMaterialBlock): this;
  57549. private _addVertexOutputNode;
  57550. private _removeVertexOutputNode;
  57551. private _addFragmentOutputNode;
  57552. private _removeFragmentOutputNode;
  57553. /**
  57554. * Specifies if the material will require alpha blending
  57555. * @returns a boolean specifying if alpha blending is needed
  57556. */
  57557. needAlphaBlending(): boolean;
  57558. /**
  57559. * Specifies if this material should be rendered in alpha test mode
  57560. * @returns a boolean specifying if an alpha test is needed.
  57561. */
  57562. needAlphaTesting(): boolean;
  57563. private _initializeBlock;
  57564. private _resetDualBlocks;
  57565. /**
  57566. * Remove a block from the current node material
  57567. * @param block defines the block to remove
  57568. */
  57569. removeBlock(block: NodeMaterialBlock): void;
  57570. /**
  57571. * Build the material and generates the inner effect
  57572. * @param verbose defines if the build should log activity
  57573. */
  57574. build(verbose?: boolean): void;
  57575. /**
  57576. * Runs an otpimization phase to try to improve the shader code
  57577. */
  57578. optimize(): void;
  57579. private _prepareDefinesForAttributes;
  57580. /**
  57581. * Get if the submesh is ready to be used and all its information available.
  57582. * Child classes can use it to update shaders
  57583. * @param mesh defines the mesh to check
  57584. * @param subMesh defines which submesh to check
  57585. * @param useInstances specifies that instances should be used
  57586. * @returns a boolean indicating that the submesh is ready or not
  57587. */
  57588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57589. /**
  57590. * Get a string representing the shaders built by the current node graph
  57591. */
  57592. get compiledShaders(): string;
  57593. /**
  57594. * Binds the world matrix to the material
  57595. * @param world defines the world transformation matrix
  57596. */
  57597. bindOnlyWorldMatrix(world: Matrix): void;
  57598. /**
  57599. * Binds the submesh to this material by preparing the effect and shader to draw
  57600. * @param world defines the world transformation matrix
  57601. * @param mesh defines the mesh containing the submesh
  57602. * @param subMesh defines the submesh to bind the material to
  57603. */
  57604. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57605. /**
  57606. * Gets the active textures from the material
  57607. * @returns an array of textures
  57608. */
  57609. getActiveTextures(): BaseTexture[];
  57610. /**
  57611. * Gets the list of texture blocks
  57612. * @returns an array of texture blocks
  57613. */
  57614. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57615. /**
  57616. * Specifies if the material uses a texture
  57617. * @param texture defines the texture to check against the material
  57618. * @returns a boolean specifying if the material uses the texture
  57619. */
  57620. hasTexture(texture: BaseTexture): boolean;
  57621. /**
  57622. * Disposes the material
  57623. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57624. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57625. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57626. */
  57627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57628. /** Creates the node editor window. */
  57629. private _createNodeEditor;
  57630. /**
  57631. * Launch the node material editor
  57632. * @param config Define the configuration of the editor
  57633. * @return a promise fulfilled when the node editor is visible
  57634. */
  57635. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57636. /**
  57637. * Clear the current material
  57638. */
  57639. clear(): void;
  57640. /**
  57641. * Clear the current material and set it to a default state
  57642. */
  57643. setToDefault(): void;
  57644. /**
  57645. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57646. * @param url defines the url to load from
  57647. * @returns a promise that will fullfil when the material is fully loaded
  57648. */
  57649. loadAsync(url: string): Promise<void>;
  57650. private _gatherBlocks;
  57651. /**
  57652. * Generate a string containing the code declaration required to create an equivalent of this material
  57653. * @returns a string
  57654. */
  57655. generateCode(): string;
  57656. /**
  57657. * Serializes this material in a JSON representation
  57658. * @returns the serialized material object
  57659. */
  57660. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57661. private _restoreConnections;
  57662. /**
  57663. * Clear the current graph and load a new one from a serialization object
  57664. * @param source defines the JSON representation of the material
  57665. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57666. */
  57667. loadFromSerialization(source: any, rootUrl?: string): void;
  57668. /**
  57669. * Makes a duplicate of the current material.
  57670. * @param name - name to use for the new material.
  57671. */
  57672. clone(name: string): NodeMaterial;
  57673. /**
  57674. * Creates a node material from parsed material data
  57675. * @param source defines the JSON representation of the material
  57676. * @param scene defines the hosting scene
  57677. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57678. * @returns a new node material
  57679. */
  57680. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57681. /**
  57682. * Creates a node material from a snippet saved in a remote file
  57683. * @param name defines the name of the material to create
  57684. * @param url defines the url to load from
  57685. * @param scene defines the hosting scene
  57686. * @returns a promise that will resolve to the new node material
  57687. */
  57688. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57689. /**
  57690. * Creates a node material from a snippet saved by the node material editor
  57691. * @param snippetId defines the snippet to load
  57692. * @param scene defines the hosting scene
  57693. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57694. * @returns a promise that will resolve to the new node material
  57695. */
  57696. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57697. /**
  57698. * Creates a new node material set to default basic configuration
  57699. * @param name defines the name of the material
  57700. * @param scene defines the hosting scene
  57701. * @returns a new NodeMaterial
  57702. */
  57703. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. /**
  57708. * Block used to read a texture from a sampler
  57709. */
  57710. export class TextureBlock extends NodeMaterialBlock {
  57711. private _defineName;
  57712. private _linearDefineName;
  57713. private _tempTextureRead;
  57714. private _samplerName;
  57715. private _transformedUVName;
  57716. private _textureTransformName;
  57717. private _textureInfoName;
  57718. private _mainUVName;
  57719. private _mainUVDefineName;
  57720. /**
  57721. * Gets or sets the texture associated with the node
  57722. */
  57723. texture: Nullable<Texture>;
  57724. /**
  57725. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57726. */
  57727. convertToGammaSpace: boolean;
  57728. /**
  57729. * Create a new TextureBlock
  57730. * @param name defines the block name
  57731. */
  57732. constructor(name: string);
  57733. /**
  57734. * Gets the current class name
  57735. * @returns the class name
  57736. */
  57737. getClassName(): string;
  57738. /**
  57739. * Gets the uv input component
  57740. */
  57741. get uv(): NodeMaterialConnectionPoint;
  57742. /**
  57743. * Gets the rgba output component
  57744. */
  57745. get rgba(): NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the rgb output component
  57748. */
  57749. get rgb(): NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the r output component
  57752. */
  57753. get r(): NodeMaterialConnectionPoint;
  57754. /**
  57755. * Gets the g output component
  57756. */
  57757. get g(): NodeMaterialConnectionPoint;
  57758. /**
  57759. * Gets the b output component
  57760. */
  57761. get b(): NodeMaterialConnectionPoint;
  57762. /**
  57763. * Gets the a output component
  57764. */
  57765. get a(): NodeMaterialConnectionPoint;
  57766. get target(): NodeMaterialBlockTargets;
  57767. autoConfigure(material: NodeMaterial): void;
  57768. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57770. isReady(): boolean;
  57771. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57772. private get _isMixed();
  57773. private _injectVertexCode;
  57774. private _writeTextureRead;
  57775. private _writeOutput;
  57776. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57777. protected _dumpPropertiesCode(): string;
  57778. serialize(): any;
  57779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57780. }
  57781. }
  57782. declare module BABYLON {
  57783. /**
  57784. * Class used to store shared data between 2 NodeMaterialBuildState
  57785. */
  57786. export class NodeMaterialBuildStateSharedData {
  57787. /**
  57788. * Gets the list of emitted varyings
  57789. */
  57790. temps: string[];
  57791. /**
  57792. * Gets the list of emitted varyings
  57793. */
  57794. varyings: string[];
  57795. /**
  57796. * Gets the varying declaration string
  57797. */
  57798. varyingDeclaration: string;
  57799. /**
  57800. * Input blocks
  57801. */
  57802. inputBlocks: InputBlock[];
  57803. /**
  57804. * Input blocks
  57805. */
  57806. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57807. /**
  57808. * Bindable blocks (Blocks that need to set data to the effect)
  57809. */
  57810. bindableBlocks: NodeMaterialBlock[];
  57811. /**
  57812. * List of blocks that can provide a compilation fallback
  57813. */
  57814. blocksWithFallbacks: NodeMaterialBlock[];
  57815. /**
  57816. * List of blocks that can provide a define update
  57817. */
  57818. blocksWithDefines: NodeMaterialBlock[];
  57819. /**
  57820. * List of blocks that can provide a repeatable content
  57821. */
  57822. repeatableContentBlocks: NodeMaterialBlock[];
  57823. /**
  57824. * List of blocks that can provide a dynamic list of uniforms
  57825. */
  57826. dynamicUniformBlocks: NodeMaterialBlock[];
  57827. /**
  57828. * List of blocks that can block the isReady function for the material
  57829. */
  57830. blockingBlocks: NodeMaterialBlock[];
  57831. /**
  57832. * Gets the list of animated inputs
  57833. */
  57834. animatedInputs: InputBlock[];
  57835. /**
  57836. * Build Id used to avoid multiple recompilations
  57837. */
  57838. buildId: number;
  57839. /** List of emitted variables */
  57840. variableNames: {
  57841. [key: string]: number;
  57842. };
  57843. /** List of emitted defines */
  57844. defineNames: {
  57845. [key: string]: number;
  57846. };
  57847. /** Should emit comments? */
  57848. emitComments: boolean;
  57849. /** Emit build activity */
  57850. verbose: boolean;
  57851. /** Gets or sets the hosting scene */
  57852. scene: Scene;
  57853. /**
  57854. * Gets the compilation hints emitted at compilation time
  57855. */
  57856. hints: {
  57857. needWorldViewMatrix: boolean;
  57858. needWorldViewProjectionMatrix: boolean;
  57859. needAlphaBlending: boolean;
  57860. needAlphaTesting: boolean;
  57861. };
  57862. /**
  57863. * List of compilation checks
  57864. */
  57865. checks: {
  57866. emitVertex: boolean;
  57867. emitFragment: boolean;
  57868. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57869. };
  57870. /** Creates a new shared data */
  57871. constructor();
  57872. /**
  57873. * Emits console errors and exceptions if there is a failing check
  57874. */
  57875. emitErrors(): void;
  57876. }
  57877. }
  57878. declare module BABYLON {
  57879. /**
  57880. * Class used to store node based material build state
  57881. */
  57882. export class NodeMaterialBuildState {
  57883. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57884. supportUniformBuffers: boolean;
  57885. /**
  57886. * Gets the list of emitted attributes
  57887. */
  57888. attributes: string[];
  57889. /**
  57890. * Gets the list of emitted uniforms
  57891. */
  57892. uniforms: string[];
  57893. /**
  57894. * Gets the list of emitted constants
  57895. */
  57896. constants: string[];
  57897. /**
  57898. * Gets the list of emitted samplers
  57899. */
  57900. samplers: string[];
  57901. /**
  57902. * Gets the list of emitted functions
  57903. */
  57904. functions: {
  57905. [key: string]: string;
  57906. };
  57907. /**
  57908. * Gets the list of emitted extensions
  57909. */
  57910. extensions: {
  57911. [key: string]: string;
  57912. };
  57913. /**
  57914. * Gets the target of the compilation state
  57915. */
  57916. target: NodeMaterialBlockTargets;
  57917. /**
  57918. * Gets the list of emitted counters
  57919. */
  57920. counters: {
  57921. [key: string]: number;
  57922. };
  57923. /**
  57924. * Shared data between multiple NodeMaterialBuildState instances
  57925. */
  57926. sharedData: NodeMaterialBuildStateSharedData;
  57927. /** @hidden */
  57928. _vertexState: NodeMaterialBuildState;
  57929. /** @hidden */
  57930. _attributeDeclaration: string;
  57931. /** @hidden */
  57932. _uniformDeclaration: string;
  57933. /** @hidden */
  57934. _constantDeclaration: string;
  57935. /** @hidden */
  57936. _samplerDeclaration: string;
  57937. /** @hidden */
  57938. _varyingTransfer: string;
  57939. private _repeatableContentAnchorIndex;
  57940. /** @hidden */
  57941. _builtCompilationString: string;
  57942. /**
  57943. * Gets the emitted compilation strings
  57944. */
  57945. compilationString: string;
  57946. /**
  57947. * Finalize the compilation strings
  57948. * @param state defines the current compilation state
  57949. */
  57950. finalize(state: NodeMaterialBuildState): void;
  57951. /** @hidden */
  57952. get _repeatableContentAnchor(): string;
  57953. /** @hidden */
  57954. _getFreeVariableName(prefix: string): string;
  57955. /** @hidden */
  57956. _getFreeDefineName(prefix: string): string;
  57957. /** @hidden */
  57958. _excludeVariableName(name: string): void;
  57959. /** @hidden */
  57960. _emit2DSampler(name: string): void;
  57961. /** @hidden */
  57962. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57963. /** @hidden */
  57964. _emitExtension(name: string, extension: string): void;
  57965. /** @hidden */
  57966. _emitFunction(name: string, code: string, comments: string): void;
  57967. /** @hidden */
  57968. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57969. replaceStrings?: {
  57970. search: RegExp;
  57971. replace: string;
  57972. }[];
  57973. repeatKey?: string;
  57974. }): string;
  57975. /** @hidden */
  57976. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57977. repeatKey?: string;
  57978. removeAttributes?: boolean;
  57979. removeUniforms?: boolean;
  57980. removeVaryings?: boolean;
  57981. removeIfDef?: boolean;
  57982. replaceStrings?: {
  57983. search: RegExp;
  57984. replace: string;
  57985. }[];
  57986. }, storeKey?: string): void;
  57987. /** @hidden */
  57988. _registerTempVariable(name: string): boolean;
  57989. /** @hidden */
  57990. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57991. /** @hidden */
  57992. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57993. /** @hidden */
  57994. _emitFloat(value: number): string;
  57995. }
  57996. }
  57997. declare module BABYLON {
  57998. /**
  57999. * Defines a block that can be used inside a node based material
  58000. */
  58001. export class NodeMaterialBlock {
  58002. private _buildId;
  58003. private _buildTarget;
  58004. private _target;
  58005. private _isFinalMerger;
  58006. private _isInput;
  58007. protected _isUnique: boolean;
  58008. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58009. inputsAreExclusive: boolean;
  58010. /** @hidden */
  58011. _codeVariableName: string;
  58012. /** @hidden */
  58013. _inputs: NodeMaterialConnectionPoint[];
  58014. /** @hidden */
  58015. _outputs: NodeMaterialConnectionPoint[];
  58016. /** @hidden */
  58017. _preparationId: number;
  58018. /**
  58019. * Gets or sets the name of the block
  58020. */
  58021. name: string;
  58022. /**
  58023. * Gets or sets the unique id of the node
  58024. */
  58025. uniqueId: number;
  58026. /**
  58027. * Gets or sets the comments associated with this block
  58028. */
  58029. comments: string;
  58030. /**
  58031. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58032. */
  58033. get isUnique(): boolean;
  58034. /**
  58035. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58036. */
  58037. get isFinalMerger(): boolean;
  58038. /**
  58039. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58040. */
  58041. get isInput(): boolean;
  58042. /**
  58043. * Gets or sets the build Id
  58044. */
  58045. get buildId(): number;
  58046. set buildId(value: number);
  58047. /**
  58048. * Gets or sets the target of the block
  58049. */
  58050. get target(): NodeMaterialBlockTargets;
  58051. set target(value: NodeMaterialBlockTargets);
  58052. /**
  58053. * Gets the list of input points
  58054. */
  58055. get inputs(): NodeMaterialConnectionPoint[];
  58056. /** Gets the list of output points */
  58057. get outputs(): NodeMaterialConnectionPoint[];
  58058. /**
  58059. * Find an input by its name
  58060. * @param name defines the name of the input to look for
  58061. * @returns the input or null if not found
  58062. */
  58063. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58064. /**
  58065. * Find an output by its name
  58066. * @param name defines the name of the outputto look for
  58067. * @returns the output or null if not found
  58068. */
  58069. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58070. /**
  58071. * Creates a new NodeMaterialBlock
  58072. * @param name defines the block name
  58073. * @param target defines the target of that block (Vertex by default)
  58074. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58075. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58076. */
  58077. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58078. /**
  58079. * Initialize the block and prepare the context for build
  58080. * @param state defines the state that will be used for the build
  58081. */
  58082. initialize(state: NodeMaterialBuildState): void;
  58083. /**
  58084. * Bind data to effect. Will only be called for blocks with isBindable === true
  58085. * @param effect defines the effect to bind data to
  58086. * @param nodeMaterial defines the hosting NodeMaterial
  58087. * @param mesh defines the mesh that will be rendered
  58088. */
  58089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58090. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58091. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58092. protected _writeFloat(value: number): string;
  58093. /**
  58094. * Gets the current class name e.g. "NodeMaterialBlock"
  58095. * @returns the class name
  58096. */
  58097. getClassName(): string;
  58098. /**
  58099. * Register a new input. Must be called inside a block constructor
  58100. * @param name defines the connection point name
  58101. * @param type defines the connection point type
  58102. * @param isOptional defines a boolean indicating that this input can be omitted
  58103. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58104. * @returns the current block
  58105. */
  58106. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58107. /**
  58108. * Register a new output. Must be called inside a block constructor
  58109. * @param name defines the connection point name
  58110. * @param type defines the connection point type
  58111. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58112. * @returns the current block
  58113. */
  58114. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58115. /**
  58116. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58117. * @param forOutput defines an optional connection point to check compatibility with
  58118. * @returns the first available input or null
  58119. */
  58120. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58121. /**
  58122. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58123. * @param forBlock defines an optional block to check compatibility with
  58124. * @returns the first available input or null
  58125. */
  58126. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58127. /**
  58128. * Gets the sibling of the given output
  58129. * @param current defines the current output
  58130. * @returns the next output in the list or null
  58131. */
  58132. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58133. /**
  58134. * Connect current block with another block
  58135. * @param other defines the block to connect with
  58136. * @param options define the various options to help pick the right connections
  58137. * @returns the current block
  58138. */
  58139. connectTo(other: NodeMaterialBlock, options?: {
  58140. input?: string;
  58141. output?: string;
  58142. outputSwizzle?: string;
  58143. }): this | undefined;
  58144. protected _buildBlock(state: NodeMaterialBuildState): void;
  58145. /**
  58146. * Add uniforms, samplers and uniform buffers at compilation time
  58147. * @param state defines the state to update
  58148. * @param nodeMaterial defines the node material requesting the update
  58149. * @param defines defines the material defines to update
  58150. * @param uniformBuffers defines the list of uniform buffer names
  58151. */
  58152. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58153. /**
  58154. * Add potential fallbacks if shader compilation fails
  58155. * @param mesh defines the mesh to be rendered
  58156. * @param fallbacks defines the current prioritized list of fallbacks
  58157. */
  58158. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58159. /**
  58160. * Initialize defines for shader compilation
  58161. * @param mesh defines the mesh to be rendered
  58162. * @param nodeMaterial defines the node material requesting the update
  58163. * @param defines defines the material defines to update
  58164. * @param useInstances specifies that instances should be used
  58165. */
  58166. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58167. /**
  58168. * Update defines for shader compilation
  58169. * @param mesh defines the mesh to be rendered
  58170. * @param nodeMaterial defines the node material requesting the update
  58171. * @param defines defines the material defines to update
  58172. * @param useInstances specifies that instances should be used
  58173. */
  58174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58175. /**
  58176. * Lets the block try to connect some inputs automatically
  58177. * @param material defines the hosting NodeMaterial
  58178. */
  58179. autoConfigure(material: NodeMaterial): void;
  58180. /**
  58181. * Function called when a block is declared as repeatable content generator
  58182. * @param vertexShaderState defines the current compilation state for the vertex shader
  58183. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58184. * @param mesh defines the mesh to be rendered
  58185. * @param defines defines the material defines to update
  58186. */
  58187. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58188. /**
  58189. * Checks if the block is ready
  58190. * @param mesh defines the mesh to be rendered
  58191. * @param nodeMaterial defines the node material requesting the update
  58192. * @param defines defines the material defines to update
  58193. * @param useInstances specifies that instances should be used
  58194. * @returns true if the block is ready
  58195. */
  58196. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58197. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58198. private _processBuild;
  58199. /**
  58200. * Compile the current node and generate the shader code
  58201. * @param state defines the current compilation state (uniforms, samplers, current string)
  58202. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58203. * @returns true if already built
  58204. */
  58205. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58206. protected _inputRename(name: string): string;
  58207. protected _outputRename(name: string): string;
  58208. protected _dumpPropertiesCode(): string;
  58209. /** @hidden */
  58210. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58211. /** @hidden */
  58212. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58213. /**
  58214. * Clone the current block to a new identical block
  58215. * @param scene defines the hosting scene
  58216. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58217. * @returns a copy of the current block
  58218. */
  58219. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58220. /**
  58221. * Serializes this block in a JSON representation
  58222. * @returns the serialized block object
  58223. */
  58224. serialize(): any;
  58225. /** @hidden */
  58226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58227. /**
  58228. * Release resources
  58229. */
  58230. dispose(): void;
  58231. }
  58232. }
  58233. declare module BABYLON {
  58234. /**
  58235. * Enum defining the type of animations supported by InputBlock
  58236. */
  58237. export enum AnimatedInputBlockTypes {
  58238. /** No animation */
  58239. None = 0,
  58240. /** Time based animation. Will only work for floats */
  58241. Time = 1
  58242. }
  58243. }
  58244. declare module BABYLON {
  58245. /**
  58246. * Block used to expose an input value
  58247. */
  58248. export class InputBlock extends NodeMaterialBlock {
  58249. private _mode;
  58250. private _associatedVariableName;
  58251. private _storedValue;
  58252. private _valueCallback;
  58253. private _type;
  58254. private _animationType;
  58255. /** Gets or set a value used to limit the range of float values */
  58256. min: number;
  58257. /** Gets or set a value used to limit the range of float values */
  58258. max: number;
  58259. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58260. isBoolean: boolean;
  58261. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58262. matrixMode: number;
  58263. /** @hidden */
  58264. _systemValue: Nullable<NodeMaterialSystemValues>;
  58265. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58266. visibleInInspector: boolean;
  58267. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58268. isConstant: boolean;
  58269. /** Gets or sets the group to use to display this block in the Inspector */
  58270. groupInInspector: string;
  58271. /** Gets an observable raised when the value is changed */
  58272. onValueChangedObservable: Observable<InputBlock>;
  58273. /**
  58274. * Gets or sets the connection point type (default is float)
  58275. */
  58276. get type(): NodeMaterialBlockConnectionPointTypes;
  58277. /**
  58278. * Creates a new InputBlock
  58279. * @param name defines the block name
  58280. * @param target defines the target of that block (Vertex by default)
  58281. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58282. */
  58283. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58284. /**
  58285. * Gets the output component
  58286. */
  58287. get output(): NodeMaterialConnectionPoint;
  58288. /**
  58289. * Set the source of this connection point to a vertex attribute
  58290. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58291. * @returns the current connection point
  58292. */
  58293. setAsAttribute(attributeName?: string): InputBlock;
  58294. /**
  58295. * Set the source of this connection point to a system value
  58296. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58297. * @returns the current connection point
  58298. */
  58299. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58300. /**
  58301. * Gets or sets the value of that point.
  58302. * Please note that this value will be ignored if valueCallback is defined
  58303. */
  58304. get value(): any;
  58305. set value(value: any);
  58306. /**
  58307. * Gets or sets a callback used to get the value of that point.
  58308. * Please note that setting this value will force the connection point to ignore the value property
  58309. */
  58310. get valueCallback(): () => any;
  58311. set valueCallback(value: () => any);
  58312. /**
  58313. * Gets or sets the associated variable name in the shader
  58314. */
  58315. get associatedVariableName(): string;
  58316. set associatedVariableName(value: string);
  58317. /** Gets or sets the type of animation applied to the input */
  58318. get animationType(): AnimatedInputBlockTypes;
  58319. set animationType(value: AnimatedInputBlockTypes);
  58320. /**
  58321. * Gets a boolean indicating that this connection point not defined yet
  58322. */
  58323. get isUndefined(): boolean;
  58324. /**
  58325. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58326. * In this case the connection point name must be the name of the uniform to use.
  58327. * Can only be set on inputs
  58328. */
  58329. get isUniform(): boolean;
  58330. set isUniform(value: boolean);
  58331. /**
  58332. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58333. * In this case the connection point name must be the name of the attribute to use
  58334. * Can only be set on inputs
  58335. */
  58336. get isAttribute(): boolean;
  58337. set isAttribute(value: boolean);
  58338. /**
  58339. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58340. * Can only be set on exit points
  58341. */
  58342. get isVarying(): boolean;
  58343. set isVarying(value: boolean);
  58344. /**
  58345. * Gets a boolean indicating that the current connection point is a system value
  58346. */
  58347. get isSystemValue(): boolean;
  58348. /**
  58349. * Gets or sets the current well known value or null if not defined as a system value
  58350. */
  58351. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58352. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58353. /**
  58354. * Gets the current class name
  58355. * @returns the class name
  58356. */
  58357. getClassName(): string;
  58358. /**
  58359. * Animate the input if animationType !== None
  58360. * @param scene defines the rendering scene
  58361. */
  58362. animate(scene: Scene): void;
  58363. private _emitDefine;
  58364. initialize(state: NodeMaterialBuildState): void;
  58365. /**
  58366. * Set the input block to its default value (based on its type)
  58367. */
  58368. setDefaultValue(): void;
  58369. private _emitConstant;
  58370. private _emit;
  58371. /** @hidden */
  58372. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58373. /** @hidden */
  58374. _transmit(effect: Effect, scene: Scene): void;
  58375. protected _buildBlock(state: NodeMaterialBuildState): void;
  58376. protected _dumpPropertiesCode(): string;
  58377. dispose(): void;
  58378. serialize(): any;
  58379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58380. }
  58381. }
  58382. declare module BABYLON {
  58383. /**
  58384. * Enum used to define the compatibility state between two connection points
  58385. */
  58386. export enum NodeMaterialConnectionPointCompatibilityStates {
  58387. /** Points are compatibles */
  58388. Compatible = 0,
  58389. /** Points are incompatible because of their types */
  58390. TypeIncompatible = 1,
  58391. /** Points are incompatible because of their targets (vertex vs fragment) */
  58392. TargetIncompatible = 2
  58393. }
  58394. /**
  58395. * Defines the direction of a connection point
  58396. */
  58397. export enum NodeMaterialConnectionPointDirection {
  58398. /** Input */
  58399. Input = 0,
  58400. /** Output */
  58401. Output = 1
  58402. }
  58403. /**
  58404. * Defines a connection point for a block
  58405. */
  58406. export class NodeMaterialConnectionPoint {
  58407. /** @hidden */
  58408. _ownerBlock: NodeMaterialBlock;
  58409. /** @hidden */
  58410. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58411. private _endpoints;
  58412. private _associatedVariableName;
  58413. private _direction;
  58414. /** @hidden */
  58415. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58416. /** @hidden */
  58417. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58418. private _type;
  58419. /** @hidden */
  58420. _enforceAssociatedVariableName: boolean;
  58421. /** Gets the direction of the point */
  58422. get direction(): NodeMaterialConnectionPointDirection;
  58423. /**
  58424. * Gets or sets the additional types supported by this connection point
  58425. */
  58426. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58427. /**
  58428. * Gets or sets the additional types excluded by this connection point
  58429. */
  58430. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58431. /**
  58432. * Observable triggered when this point is connected
  58433. */
  58434. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58435. /**
  58436. * Gets or sets the associated variable name in the shader
  58437. */
  58438. get associatedVariableName(): string;
  58439. set associatedVariableName(value: string);
  58440. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58441. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58442. /**
  58443. * Gets or sets the connection point type (default is float)
  58444. */
  58445. get type(): NodeMaterialBlockConnectionPointTypes;
  58446. set type(value: NodeMaterialBlockConnectionPointTypes);
  58447. /**
  58448. * Gets or sets the connection point name
  58449. */
  58450. name: string;
  58451. /**
  58452. * Gets or sets a boolean indicating that this connection point can be omitted
  58453. */
  58454. isOptional: boolean;
  58455. /**
  58456. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58457. */
  58458. define: string;
  58459. /** @hidden */
  58460. _prioritizeVertex: boolean;
  58461. private _target;
  58462. /** Gets or sets the target of that connection point */
  58463. get target(): NodeMaterialBlockTargets;
  58464. set target(value: NodeMaterialBlockTargets);
  58465. /**
  58466. * Gets a boolean indicating that the current point is connected
  58467. */
  58468. get isConnected(): boolean;
  58469. /**
  58470. * Gets a boolean indicating that the current point is connected to an input block
  58471. */
  58472. get isConnectedToInputBlock(): boolean;
  58473. /**
  58474. * Gets a the connected input block (if any)
  58475. */
  58476. get connectInputBlock(): Nullable<InputBlock>;
  58477. /** Get the other side of the connection (if any) */
  58478. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58479. /** Get the block that owns this connection point */
  58480. get ownerBlock(): NodeMaterialBlock;
  58481. /** Get the block connected on the other side of this connection (if any) */
  58482. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58483. /** Get the block connected on the endpoints of this connection (if any) */
  58484. get connectedBlocks(): Array<NodeMaterialBlock>;
  58485. /** Gets the list of connected endpoints */
  58486. get endpoints(): NodeMaterialConnectionPoint[];
  58487. /** Gets a boolean indicating if that output point is connected to at least one input */
  58488. get hasEndpoints(): boolean;
  58489. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58490. get isConnectedInVertexShader(): boolean;
  58491. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58492. get isConnectedInFragmentShader(): boolean;
  58493. /**
  58494. * Creates a new connection point
  58495. * @param name defines the connection point name
  58496. * @param ownerBlock defines the block hosting this connection point
  58497. * @param direction defines the direction of the connection point
  58498. */
  58499. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58500. /**
  58501. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58502. * @returns the class name
  58503. */
  58504. getClassName(): string;
  58505. /**
  58506. * Gets a boolean indicating if the current point can be connected to another point
  58507. * @param connectionPoint defines the other connection point
  58508. * @returns a boolean
  58509. */
  58510. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58511. /**
  58512. * Gets a number indicating if the current point can be connected to another point
  58513. * @param connectionPoint defines the other connection point
  58514. * @returns a number defining the compatibility state
  58515. */
  58516. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58517. /**
  58518. * Connect this point to another connection point
  58519. * @param connectionPoint defines the other connection point
  58520. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58521. * @returns the current connection point
  58522. */
  58523. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58524. /**
  58525. * Disconnect this point from one of his endpoint
  58526. * @param endpoint defines the other connection point
  58527. * @returns the current connection point
  58528. */
  58529. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58530. /**
  58531. * Serializes this point in a JSON representation
  58532. * @returns the serialized point object
  58533. */
  58534. serialize(): any;
  58535. /**
  58536. * Release resources
  58537. */
  58538. dispose(): void;
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /**
  58543. * Block used to add support for vertex skinning (bones)
  58544. */
  58545. export class BonesBlock extends NodeMaterialBlock {
  58546. /**
  58547. * Creates a new BonesBlock
  58548. * @param name defines the block name
  58549. */
  58550. constructor(name: string);
  58551. /**
  58552. * Initialize the block and prepare the context for build
  58553. * @param state defines the state that will be used for the build
  58554. */
  58555. initialize(state: NodeMaterialBuildState): void;
  58556. /**
  58557. * Gets the current class name
  58558. * @returns the class name
  58559. */
  58560. getClassName(): string;
  58561. /**
  58562. * Gets the matrix indices input component
  58563. */
  58564. get matricesIndices(): NodeMaterialConnectionPoint;
  58565. /**
  58566. * Gets the matrix weights input component
  58567. */
  58568. get matricesWeights(): NodeMaterialConnectionPoint;
  58569. /**
  58570. * Gets the extra matrix indices input component
  58571. */
  58572. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58573. /**
  58574. * Gets the extra matrix weights input component
  58575. */
  58576. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the world input component
  58579. */
  58580. get world(): NodeMaterialConnectionPoint;
  58581. /**
  58582. * Gets the output component
  58583. */
  58584. get output(): NodeMaterialConnectionPoint;
  58585. autoConfigure(material: NodeMaterial): void;
  58586. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58589. protected _buildBlock(state: NodeMaterialBuildState): this;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * Block used to add support for instances
  58595. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58596. */
  58597. export class InstancesBlock extends NodeMaterialBlock {
  58598. /**
  58599. * Creates a new InstancesBlock
  58600. * @param name defines the block name
  58601. */
  58602. constructor(name: string);
  58603. /**
  58604. * Gets the current class name
  58605. * @returns the class name
  58606. */
  58607. getClassName(): string;
  58608. /**
  58609. * Gets the first world row input component
  58610. */
  58611. get world0(): NodeMaterialConnectionPoint;
  58612. /**
  58613. * Gets the second world row input component
  58614. */
  58615. get world1(): NodeMaterialConnectionPoint;
  58616. /**
  58617. * Gets the third world row input component
  58618. */
  58619. get world2(): NodeMaterialConnectionPoint;
  58620. /**
  58621. * Gets the forth world row input component
  58622. */
  58623. get world3(): NodeMaterialConnectionPoint;
  58624. /**
  58625. * Gets the world input component
  58626. */
  58627. get world(): NodeMaterialConnectionPoint;
  58628. /**
  58629. * Gets the output component
  58630. */
  58631. get output(): NodeMaterialConnectionPoint;
  58632. /**
  58633. * Gets the isntanceID component
  58634. */
  58635. get instanceID(): NodeMaterialConnectionPoint;
  58636. autoConfigure(material: NodeMaterial): void;
  58637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58638. protected _buildBlock(state: NodeMaterialBuildState): this;
  58639. }
  58640. }
  58641. declare module BABYLON {
  58642. /**
  58643. * Block used to add morph targets support to vertex shader
  58644. */
  58645. export class MorphTargetsBlock extends NodeMaterialBlock {
  58646. private _repeatableContentAnchor;
  58647. /**
  58648. * Create a new MorphTargetsBlock
  58649. * @param name defines the block name
  58650. */
  58651. constructor(name: string);
  58652. /**
  58653. * Gets the current class name
  58654. * @returns the class name
  58655. */
  58656. getClassName(): string;
  58657. /**
  58658. * Gets the position input component
  58659. */
  58660. get position(): NodeMaterialConnectionPoint;
  58661. /**
  58662. * Gets the normal input component
  58663. */
  58664. get normal(): NodeMaterialConnectionPoint;
  58665. /**
  58666. * Gets the tangent input component
  58667. */
  58668. get tangent(): NodeMaterialConnectionPoint;
  58669. /**
  58670. * Gets the tangent input component
  58671. */
  58672. get uv(): NodeMaterialConnectionPoint;
  58673. /**
  58674. * Gets the position output component
  58675. */
  58676. get positionOutput(): NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the normal output component
  58679. */
  58680. get normalOutput(): NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the tangent output component
  58683. */
  58684. get tangentOutput(): NodeMaterialConnectionPoint;
  58685. /**
  58686. * Gets the tangent output component
  58687. */
  58688. get uvOutput(): NodeMaterialConnectionPoint;
  58689. initialize(state: NodeMaterialBuildState): void;
  58690. autoConfigure(material: NodeMaterial): void;
  58691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58692. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58693. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58694. protected _buildBlock(state: NodeMaterialBuildState): this;
  58695. }
  58696. }
  58697. declare module BABYLON {
  58698. /**
  58699. * Block used to get data information from a light
  58700. */
  58701. export class LightInformationBlock extends NodeMaterialBlock {
  58702. private _lightDataUniformName;
  58703. private _lightColorUniformName;
  58704. private _lightTypeDefineName;
  58705. /**
  58706. * Gets or sets the light associated with this block
  58707. */
  58708. light: Nullable<Light>;
  58709. /**
  58710. * Creates a new LightInformationBlock
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the world position input component
  58721. */
  58722. get worldPosition(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the direction output component
  58725. */
  58726. get direction(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the direction output component
  58729. */
  58730. get color(): NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the direction output component
  58733. */
  58734. get intensity(): NodeMaterialConnectionPoint;
  58735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58737. protected _buildBlock(state: NodeMaterialBuildState): this;
  58738. serialize(): any;
  58739. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58740. }
  58741. }
  58742. declare module BABYLON {
  58743. /**
  58744. * Block used to add image processing support to fragment shader
  58745. */
  58746. export class ImageProcessingBlock extends NodeMaterialBlock {
  58747. /**
  58748. * Create a new ImageProcessingBlock
  58749. * @param name defines the block name
  58750. */
  58751. constructor(name: string);
  58752. /**
  58753. * Gets the current class name
  58754. * @returns the class name
  58755. */
  58756. getClassName(): string;
  58757. /**
  58758. * Gets the color input component
  58759. */
  58760. get color(): NodeMaterialConnectionPoint;
  58761. /**
  58762. * Gets the output component
  58763. */
  58764. get output(): NodeMaterialConnectionPoint;
  58765. /**
  58766. * Initialize the block and prepare the context for build
  58767. * @param state defines the state that will be used for the build
  58768. */
  58769. initialize(state: NodeMaterialBuildState): void;
  58770. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58773. protected _buildBlock(state: NodeMaterialBuildState): this;
  58774. }
  58775. }
  58776. declare module BABYLON {
  58777. /**
  58778. * Block used to pertub normals based on a normal map
  58779. */
  58780. export class PerturbNormalBlock extends NodeMaterialBlock {
  58781. private _tangentSpaceParameterName;
  58782. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58783. invertX: boolean;
  58784. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58785. invertY: boolean;
  58786. /**
  58787. * Create a new PerturbNormalBlock
  58788. * @param name defines the block name
  58789. */
  58790. constructor(name: string);
  58791. /**
  58792. * Gets the current class name
  58793. * @returns the class name
  58794. */
  58795. getClassName(): string;
  58796. /**
  58797. * Gets the world position input component
  58798. */
  58799. get worldPosition(): NodeMaterialConnectionPoint;
  58800. /**
  58801. * Gets the world normal input component
  58802. */
  58803. get worldNormal(): NodeMaterialConnectionPoint;
  58804. /**
  58805. * Gets the world tangent input component
  58806. */
  58807. get worldTangent(): NodeMaterialConnectionPoint;
  58808. /**
  58809. * Gets the uv input component
  58810. */
  58811. get uv(): NodeMaterialConnectionPoint;
  58812. /**
  58813. * Gets the normal map color input component
  58814. */
  58815. get normalMapColor(): NodeMaterialConnectionPoint;
  58816. /**
  58817. * Gets the strength input component
  58818. */
  58819. get strength(): NodeMaterialConnectionPoint;
  58820. /**
  58821. * Gets the output component
  58822. */
  58823. get output(): NodeMaterialConnectionPoint;
  58824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58826. autoConfigure(material: NodeMaterial): void;
  58827. protected _buildBlock(state: NodeMaterialBuildState): this;
  58828. protected _dumpPropertiesCode(): string;
  58829. serialize(): any;
  58830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58831. }
  58832. }
  58833. declare module BABYLON {
  58834. /**
  58835. * Block used to discard a pixel if a value is smaller than a cutoff
  58836. */
  58837. export class DiscardBlock extends NodeMaterialBlock {
  58838. /**
  58839. * Create a new DiscardBlock
  58840. * @param name defines the block name
  58841. */
  58842. constructor(name: string);
  58843. /**
  58844. * Gets the current class name
  58845. * @returns the class name
  58846. */
  58847. getClassName(): string;
  58848. /**
  58849. * Gets the color input component
  58850. */
  58851. get value(): NodeMaterialConnectionPoint;
  58852. /**
  58853. * Gets the cutoff input component
  58854. */
  58855. get cutoff(): NodeMaterialConnectionPoint;
  58856. protected _buildBlock(state: NodeMaterialBuildState): this;
  58857. }
  58858. }
  58859. declare module BABYLON {
  58860. /**
  58861. * Block used to test if the fragment shader is front facing
  58862. */
  58863. export class FrontFacingBlock extends NodeMaterialBlock {
  58864. /**
  58865. * Creates a new FrontFacingBlock
  58866. * @param name defines the block name
  58867. */
  58868. constructor(name: string);
  58869. /**
  58870. * Gets the current class name
  58871. * @returns the class name
  58872. */
  58873. getClassName(): string;
  58874. /**
  58875. * Gets the output component
  58876. */
  58877. get output(): NodeMaterialConnectionPoint;
  58878. protected _buildBlock(state: NodeMaterialBuildState): this;
  58879. }
  58880. }
  58881. declare module BABYLON {
  58882. /**
  58883. * Block used to get the derivative value on x and y of a given input
  58884. */
  58885. export class DerivativeBlock extends NodeMaterialBlock {
  58886. /**
  58887. * Create a new DerivativeBlock
  58888. * @param name defines the block name
  58889. */
  58890. constructor(name: string);
  58891. /**
  58892. * Gets the current class name
  58893. * @returns the class name
  58894. */
  58895. getClassName(): string;
  58896. /**
  58897. * Gets the input component
  58898. */
  58899. get input(): NodeMaterialConnectionPoint;
  58900. /**
  58901. * Gets the derivative output on x
  58902. */
  58903. get dx(): NodeMaterialConnectionPoint;
  58904. /**
  58905. * Gets the derivative output on y
  58906. */
  58907. get dy(): NodeMaterialConnectionPoint;
  58908. protected _buildBlock(state: NodeMaterialBuildState): this;
  58909. }
  58910. }
  58911. declare module BABYLON {
  58912. /**
  58913. * Block used to add support for scene fog
  58914. */
  58915. export class FogBlock extends NodeMaterialBlock {
  58916. private _fogDistanceName;
  58917. private _fogParameters;
  58918. /**
  58919. * Create a new FogBlock
  58920. * @param name defines the block name
  58921. */
  58922. constructor(name: string);
  58923. /**
  58924. * Gets the current class name
  58925. * @returns the class name
  58926. */
  58927. getClassName(): string;
  58928. /**
  58929. * Gets the world position input component
  58930. */
  58931. get worldPosition(): NodeMaterialConnectionPoint;
  58932. /**
  58933. * Gets the view input component
  58934. */
  58935. get view(): NodeMaterialConnectionPoint;
  58936. /**
  58937. * Gets the color input component
  58938. */
  58939. get input(): NodeMaterialConnectionPoint;
  58940. /**
  58941. * Gets the fog color input component
  58942. */
  58943. get fogColor(): NodeMaterialConnectionPoint;
  58944. /**
  58945. * Gets the output component
  58946. */
  58947. get output(): NodeMaterialConnectionPoint;
  58948. autoConfigure(material: NodeMaterial): void;
  58949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58951. protected _buildBlock(state: NodeMaterialBuildState): this;
  58952. }
  58953. }
  58954. declare module BABYLON {
  58955. /**
  58956. * Block used to add light in the fragment shader
  58957. */
  58958. export class LightBlock extends NodeMaterialBlock {
  58959. private _lightId;
  58960. /**
  58961. * Gets or sets the light associated with this block
  58962. */
  58963. light: Nullable<Light>;
  58964. /**
  58965. * Create a new LightBlock
  58966. * @param name defines the block name
  58967. */
  58968. constructor(name: string);
  58969. /**
  58970. * Gets the current class name
  58971. * @returns the class name
  58972. */
  58973. getClassName(): string;
  58974. /**
  58975. * Gets the world position input component
  58976. */
  58977. get worldPosition(): NodeMaterialConnectionPoint;
  58978. /**
  58979. * Gets the world normal input component
  58980. */
  58981. get worldNormal(): NodeMaterialConnectionPoint;
  58982. /**
  58983. * Gets the camera (or eye) position component
  58984. */
  58985. get cameraPosition(): NodeMaterialConnectionPoint;
  58986. /**
  58987. * Gets the glossiness component
  58988. */
  58989. get glossiness(): NodeMaterialConnectionPoint;
  58990. /**
  58991. * Gets the glossinness power component
  58992. */
  58993. get glossPower(): NodeMaterialConnectionPoint;
  58994. /**
  58995. * Gets the diffuse color component
  58996. */
  58997. get diffuseColor(): NodeMaterialConnectionPoint;
  58998. /**
  58999. * Gets the specular color component
  59000. */
  59001. get specularColor(): NodeMaterialConnectionPoint;
  59002. /**
  59003. * Gets the diffuse output component
  59004. */
  59005. get diffuseOutput(): NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the specular output component
  59008. */
  59009. get specularOutput(): NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the shadow output component
  59012. */
  59013. get shadow(): NodeMaterialConnectionPoint;
  59014. autoConfigure(material: NodeMaterial): void;
  59015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59016. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59018. private _injectVertexCode;
  59019. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59020. serialize(): any;
  59021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59022. }
  59023. }
  59024. declare module BABYLON {
  59025. /**
  59026. * Block used to multiply 2 values
  59027. */
  59028. export class MultiplyBlock extends NodeMaterialBlock {
  59029. /**
  59030. * Creates a new MultiplyBlock
  59031. * @param name defines the block name
  59032. */
  59033. constructor(name: string);
  59034. /**
  59035. * Gets the current class name
  59036. * @returns the class name
  59037. */
  59038. getClassName(): string;
  59039. /**
  59040. * Gets the left operand input component
  59041. */
  59042. get left(): NodeMaterialConnectionPoint;
  59043. /**
  59044. * Gets the right operand input component
  59045. */
  59046. get right(): NodeMaterialConnectionPoint;
  59047. /**
  59048. * Gets the output component
  59049. */
  59050. get output(): NodeMaterialConnectionPoint;
  59051. protected _buildBlock(state: NodeMaterialBuildState): this;
  59052. }
  59053. }
  59054. declare module BABYLON {
  59055. /**
  59056. * Block used to add 2 vectors
  59057. */
  59058. export class AddBlock extends NodeMaterialBlock {
  59059. /**
  59060. * Creates a new AddBlock
  59061. * @param name defines the block name
  59062. */
  59063. constructor(name: string);
  59064. /**
  59065. * Gets the current class name
  59066. * @returns the class name
  59067. */
  59068. getClassName(): string;
  59069. /**
  59070. * Gets the left operand input component
  59071. */
  59072. get left(): NodeMaterialConnectionPoint;
  59073. /**
  59074. * Gets the right operand input component
  59075. */
  59076. get right(): NodeMaterialConnectionPoint;
  59077. /**
  59078. * Gets the output component
  59079. */
  59080. get output(): NodeMaterialConnectionPoint;
  59081. protected _buildBlock(state: NodeMaterialBuildState): this;
  59082. }
  59083. }
  59084. declare module BABYLON {
  59085. /**
  59086. * Block used to scale a vector by a float
  59087. */
  59088. export class ScaleBlock extends NodeMaterialBlock {
  59089. /**
  59090. * Creates a new ScaleBlock
  59091. * @param name defines the block name
  59092. */
  59093. constructor(name: string);
  59094. /**
  59095. * Gets the current class name
  59096. * @returns the class name
  59097. */
  59098. getClassName(): string;
  59099. /**
  59100. * Gets the input component
  59101. */
  59102. get input(): NodeMaterialConnectionPoint;
  59103. /**
  59104. * Gets the factor input component
  59105. */
  59106. get factor(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Gets the output component
  59109. */
  59110. get output(): NodeMaterialConnectionPoint;
  59111. protected _buildBlock(state: NodeMaterialBuildState): this;
  59112. }
  59113. }
  59114. declare module BABYLON {
  59115. /**
  59116. * Block used to clamp a float
  59117. */
  59118. export class ClampBlock extends NodeMaterialBlock {
  59119. /** Gets or sets the minimum range */
  59120. minimum: number;
  59121. /** Gets or sets the maximum range */
  59122. maximum: number;
  59123. /**
  59124. * Creates a new ClampBlock
  59125. * @param name defines the block name
  59126. */
  59127. constructor(name: string);
  59128. /**
  59129. * Gets the current class name
  59130. * @returns the class name
  59131. */
  59132. getClassName(): string;
  59133. /**
  59134. * Gets the value input component
  59135. */
  59136. get value(): NodeMaterialConnectionPoint;
  59137. /**
  59138. * Gets the output component
  59139. */
  59140. get output(): NodeMaterialConnectionPoint;
  59141. protected _buildBlock(state: NodeMaterialBuildState): this;
  59142. protected _dumpPropertiesCode(): string;
  59143. serialize(): any;
  59144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59145. }
  59146. }
  59147. declare module BABYLON {
  59148. /**
  59149. * Block used to apply a cross product between 2 vectors
  59150. */
  59151. export class CrossBlock extends NodeMaterialBlock {
  59152. /**
  59153. * Creates a new CrossBlock
  59154. * @param name defines the block name
  59155. */
  59156. constructor(name: string);
  59157. /**
  59158. * Gets the current class name
  59159. * @returns the class name
  59160. */
  59161. getClassName(): string;
  59162. /**
  59163. * Gets the left operand input component
  59164. */
  59165. get left(): NodeMaterialConnectionPoint;
  59166. /**
  59167. * Gets the right operand input component
  59168. */
  59169. get right(): NodeMaterialConnectionPoint;
  59170. /**
  59171. * Gets the output component
  59172. */
  59173. get output(): NodeMaterialConnectionPoint;
  59174. protected _buildBlock(state: NodeMaterialBuildState): this;
  59175. }
  59176. }
  59177. declare module BABYLON {
  59178. /**
  59179. * Block used to apply a dot product between 2 vectors
  59180. */
  59181. export class DotBlock extends NodeMaterialBlock {
  59182. /**
  59183. * Creates a new DotBlock
  59184. * @param name defines the block name
  59185. */
  59186. constructor(name: string);
  59187. /**
  59188. * Gets the current class name
  59189. * @returns the class name
  59190. */
  59191. getClassName(): string;
  59192. /**
  59193. * Gets the left operand input component
  59194. */
  59195. get left(): NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the right operand input component
  59198. */
  59199. get right(): NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the output component
  59202. */
  59203. get output(): NodeMaterialConnectionPoint;
  59204. protected _buildBlock(state: NodeMaterialBuildState): this;
  59205. }
  59206. }
  59207. declare module BABYLON {
  59208. /**
  59209. * Block used to remap a float from a range to a new one
  59210. */
  59211. export class RemapBlock extends NodeMaterialBlock {
  59212. /**
  59213. * Gets or sets the source range
  59214. */
  59215. sourceRange: Vector2;
  59216. /**
  59217. * Gets or sets the target range
  59218. */
  59219. targetRange: Vector2;
  59220. /**
  59221. * Creates a new RemapBlock
  59222. * @param name defines the block name
  59223. */
  59224. constructor(name: string);
  59225. /**
  59226. * Gets the current class name
  59227. * @returns the class name
  59228. */
  59229. getClassName(): string;
  59230. /**
  59231. * Gets the input component
  59232. */
  59233. get input(): NodeMaterialConnectionPoint;
  59234. /**
  59235. * Gets the source min input component
  59236. */
  59237. get sourceMin(): NodeMaterialConnectionPoint;
  59238. /**
  59239. * Gets the source max input component
  59240. */
  59241. get sourceMax(): NodeMaterialConnectionPoint;
  59242. /**
  59243. * Gets the target min input component
  59244. */
  59245. get targetMin(): NodeMaterialConnectionPoint;
  59246. /**
  59247. * Gets the target max input component
  59248. */
  59249. get targetMax(): NodeMaterialConnectionPoint;
  59250. /**
  59251. * Gets the output component
  59252. */
  59253. get output(): NodeMaterialConnectionPoint;
  59254. protected _buildBlock(state: NodeMaterialBuildState): this;
  59255. protected _dumpPropertiesCode(): string;
  59256. serialize(): any;
  59257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59258. }
  59259. }
  59260. declare module BABYLON {
  59261. /**
  59262. * Block used to normalize a vector
  59263. */
  59264. export class NormalizeBlock extends NodeMaterialBlock {
  59265. /**
  59266. * Creates a new NormalizeBlock
  59267. * @param name defines the block name
  59268. */
  59269. constructor(name: string);
  59270. /**
  59271. * Gets the current class name
  59272. * @returns the class name
  59273. */
  59274. getClassName(): string;
  59275. /**
  59276. * Gets the input component
  59277. */
  59278. get input(): NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the output component
  59281. */
  59282. get output(): NodeMaterialConnectionPoint;
  59283. protected _buildBlock(state: NodeMaterialBuildState): this;
  59284. }
  59285. }
  59286. declare module BABYLON {
  59287. /**
  59288. * Operations supported by the Trigonometry block
  59289. */
  59290. export enum TrigonometryBlockOperations {
  59291. /** Cos */
  59292. Cos = 0,
  59293. /** Sin */
  59294. Sin = 1,
  59295. /** Abs */
  59296. Abs = 2,
  59297. /** Exp */
  59298. Exp = 3,
  59299. /** Exp2 */
  59300. Exp2 = 4,
  59301. /** Round */
  59302. Round = 5,
  59303. /** Floor */
  59304. Floor = 6,
  59305. /** Ceiling */
  59306. Ceiling = 7,
  59307. /** Square root */
  59308. Sqrt = 8,
  59309. /** Log */
  59310. Log = 9,
  59311. /** Tangent */
  59312. Tan = 10,
  59313. /** Arc tangent */
  59314. ArcTan = 11,
  59315. /** Arc cosinus */
  59316. ArcCos = 12,
  59317. /** Arc sinus */
  59318. ArcSin = 13,
  59319. /** Fraction */
  59320. Fract = 14,
  59321. /** Sign */
  59322. Sign = 15,
  59323. /** To radians (from degrees) */
  59324. Radians = 16,
  59325. /** To degrees (from radians) */
  59326. Degrees = 17
  59327. }
  59328. /**
  59329. * Block used to apply trigonometry operation to floats
  59330. */
  59331. export class TrigonometryBlock extends NodeMaterialBlock {
  59332. /**
  59333. * Gets or sets the operation applied by the block
  59334. */
  59335. operation: TrigonometryBlockOperations;
  59336. /**
  59337. * Creates a new TrigonometryBlock
  59338. * @param name defines the block name
  59339. */
  59340. constructor(name: string);
  59341. /**
  59342. * Gets the current class name
  59343. * @returns the class name
  59344. */
  59345. getClassName(): string;
  59346. /**
  59347. * Gets the input component
  59348. */
  59349. get input(): NodeMaterialConnectionPoint;
  59350. /**
  59351. * Gets the output component
  59352. */
  59353. get output(): NodeMaterialConnectionPoint;
  59354. protected _buildBlock(state: NodeMaterialBuildState): this;
  59355. serialize(): any;
  59356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59357. protected _dumpPropertiesCode(): string;
  59358. }
  59359. }
  59360. declare module BABYLON {
  59361. /**
  59362. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59363. */
  59364. export class ColorMergerBlock extends NodeMaterialBlock {
  59365. /**
  59366. * Create a new ColorMergerBlock
  59367. * @param name defines the block name
  59368. */
  59369. constructor(name: string);
  59370. /**
  59371. * Gets the current class name
  59372. * @returns the class name
  59373. */
  59374. getClassName(): string;
  59375. /**
  59376. * Gets the rgb component (input)
  59377. */
  59378. get rgbIn(): NodeMaterialConnectionPoint;
  59379. /**
  59380. * Gets the r component (input)
  59381. */
  59382. get r(): NodeMaterialConnectionPoint;
  59383. /**
  59384. * Gets the g component (input)
  59385. */
  59386. get g(): NodeMaterialConnectionPoint;
  59387. /**
  59388. * Gets the b component (input)
  59389. */
  59390. get b(): NodeMaterialConnectionPoint;
  59391. /**
  59392. * Gets the a component (input)
  59393. */
  59394. get a(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the rgba component (output)
  59397. */
  59398. get rgba(): NodeMaterialConnectionPoint;
  59399. /**
  59400. * Gets the rgb component (output)
  59401. */
  59402. get rgbOut(): NodeMaterialConnectionPoint;
  59403. /**
  59404. * Gets the rgb component (output)
  59405. * @deprecated Please use rgbOut instead.
  59406. */
  59407. get rgb(): NodeMaterialConnectionPoint;
  59408. protected _buildBlock(state: NodeMaterialBuildState): this;
  59409. }
  59410. }
  59411. declare module BABYLON {
  59412. /**
  59413. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59414. */
  59415. export class VectorMergerBlock extends NodeMaterialBlock {
  59416. /**
  59417. * Create a new VectorMergerBlock
  59418. * @param name defines the block name
  59419. */
  59420. constructor(name: string);
  59421. /**
  59422. * Gets the current class name
  59423. * @returns the class name
  59424. */
  59425. getClassName(): string;
  59426. /**
  59427. * Gets the xyz component (input)
  59428. */
  59429. get xyzIn(): NodeMaterialConnectionPoint;
  59430. /**
  59431. * Gets the xy component (input)
  59432. */
  59433. get xyIn(): NodeMaterialConnectionPoint;
  59434. /**
  59435. * Gets the x component (input)
  59436. */
  59437. get x(): NodeMaterialConnectionPoint;
  59438. /**
  59439. * Gets the y component (input)
  59440. */
  59441. get y(): NodeMaterialConnectionPoint;
  59442. /**
  59443. * Gets the z component (input)
  59444. */
  59445. get z(): NodeMaterialConnectionPoint;
  59446. /**
  59447. * Gets the w component (input)
  59448. */
  59449. get w(): NodeMaterialConnectionPoint;
  59450. /**
  59451. * Gets the xyzw component (output)
  59452. */
  59453. get xyzw(): NodeMaterialConnectionPoint;
  59454. /**
  59455. * Gets the xyz component (output)
  59456. */
  59457. get xyzOut(): NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the xy component (output)
  59460. */
  59461. get xyOut(): NodeMaterialConnectionPoint;
  59462. /**
  59463. * Gets the xy component (output)
  59464. * @deprecated Please use xyOut instead.
  59465. */
  59466. get xy(): NodeMaterialConnectionPoint;
  59467. /**
  59468. * Gets the xyz component (output)
  59469. * @deprecated Please use xyzOut instead.
  59470. */
  59471. get xyz(): NodeMaterialConnectionPoint;
  59472. protected _buildBlock(state: NodeMaterialBuildState): this;
  59473. }
  59474. }
  59475. declare module BABYLON {
  59476. /**
  59477. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59478. */
  59479. export class ColorSplitterBlock extends NodeMaterialBlock {
  59480. /**
  59481. * Create a new ColorSplitterBlock
  59482. * @param name defines the block name
  59483. */
  59484. constructor(name: string);
  59485. /**
  59486. * Gets the current class name
  59487. * @returns the class name
  59488. */
  59489. getClassName(): string;
  59490. /**
  59491. * Gets the rgba component (input)
  59492. */
  59493. get rgba(): NodeMaterialConnectionPoint;
  59494. /**
  59495. * Gets the rgb component (input)
  59496. */
  59497. get rgbIn(): NodeMaterialConnectionPoint;
  59498. /**
  59499. * Gets the rgb component (output)
  59500. */
  59501. get rgbOut(): NodeMaterialConnectionPoint;
  59502. /**
  59503. * Gets the r component (output)
  59504. */
  59505. get r(): NodeMaterialConnectionPoint;
  59506. /**
  59507. * Gets the g component (output)
  59508. */
  59509. get g(): NodeMaterialConnectionPoint;
  59510. /**
  59511. * Gets the b component (output)
  59512. */
  59513. get b(): NodeMaterialConnectionPoint;
  59514. /**
  59515. * Gets the a component (output)
  59516. */
  59517. get a(): NodeMaterialConnectionPoint;
  59518. protected _inputRename(name: string): string;
  59519. protected _outputRename(name: string): string;
  59520. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59521. }
  59522. }
  59523. declare module BABYLON {
  59524. /**
  59525. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59526. */
  59527. export class VectorSplitterBlock extends NodeMaterialBlock {
  59528. /**
  59529. * Create a new VectorSplitterBlock
  59530. * @param name defines the block name
  59531. */
  59532. constructor(name: string);
  59533. /**
  59534. * Gets the current class name
  59535. * @returns the class name
  59536. */
  59537. getClassName(): string;
  59538. /**
  59539. * Gets the xyzw component (input)
  59540. */
  59541. get xyzw(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the xyz component (input)
  59544. */
  59545. get xyzIn(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the xy component (input)
  59548. */
  59549. get xyIn(): NodeMaterialConnectionPoint;
  59550. /**
  59551. * Gets the xyz component (output)
  59552. */
  59553. get xyzOut(): NodeMaterialConnectionPoint;
  59554. /**
  59555. * Gets the xy component (output)
  59556. */
  59557. get xyOut(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the x component (output)
  59560. */
  59561. get x(): NodeMaterialConnectionPoint;
  59562. /**
  59563. * Gets the y component (output)
  59564. */
  59565. get y(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Gets the z component (output)
  59568. */
  59569. get z(): NodeMaterialConnectionPoint;
  59570. /**
  59571. * Gets the w component (output)
  59572. */
  59573. get w(): NodeMaterialConnectionPoint;
  59574. protected _inputRename(name: string): string;
  59575. protected _outputRename(name: string): string;
  59576. protected _buildBlock(state: NodeMaterialBuildState): this;
  59577. }
  59578. }
  59579. declare module BABYLON {
  59580. /**
  59581. * Block used to lerp between 2 values
  59582. */
  59583. export class LerpBlock extends NodeMaterialBlock {
  59584. /**
  59585. * Creates a new LerpBlock
  59586. * @param name defines the block name
  59587. */
  59588. constructor(name: string);
  59589. /**
  59590. * Gets the current class name
  59591. * @returns the class name
  59592. */
  59593. getClassName(): string;
  59594. /**
  59595. * Gets the left operand input component
  59596. */
  59597. get left(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the right operand input component
  59600. */
  59601. get right(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the gradient operand input component
  59604. */
  59605. get gradient(): NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the output component
  59608. */
  59609. get output(): NodeMaterialConnectionPoint;
  59610. protected _buildBlock(state: NodeMaterialBuildState): this;
  59611. }
  59612. }
  59613. declare module BABYLON {
  59614. /**
  59615. * Block used to divide 2 vectors
  59616. */
  59617. export class DivideBlock extends NodeMaterialBlock {
  59618. /**
  59619. * Creates a new DivideBlock
  59620. * @param name defines the block name
  59621. */
  59622. constructor(name: string);
  59623. /**
  59624. * Gets the current class name
  59625. * @returns the class name
  59626. */
  59627. getClassName(): string;
  59628. /**
  59629. * Gets the left operand input component
  59630. */
  59631. get left(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the right operand input component
  59634. */
  59635. get right(): NodeMaterialConnectionPoint;
  59636. /**
  59637. * Gets the output component
  59638. */
  59639. get output(): NodeMaterialConnectionPoint;
  59640. protected _buildBlock(state: NodeMaterialBuildState): this;
  59641. }
  59642. }
  59643. declare module BABYLON {
  59644. /**
  59645. * Block used to subtract 2 vectors
  59646. */
  59647. export class SubtractBlock extends NodeMaterialBlock {
  59648. /**
  59649. * Creates a new SubtractBlock
  59650. * @param name defines the block name
  59651. */
  59652. constructor(name: string);
  59653. /**
  59654. * Gets the current class name
  59655. * @returns the class name
  59656. */
  59657. getClassName(): string;
  59658. /**
  59659. * Gets the left operand input component
  59660. */
  59661. get left(): NodeMaterialConnectionPoint;
  59662. /**
  59663. * Gets the right operand input component
  59664. */
  59665. get right(): NodeMaterialConnectionPoint;
  59666. /**
  59667. * Gets the output component
  59668. */
  59669. get output(): NodeMaterialConnectionPoint;
  59670. protected _buildBlock(state: NodeMaterialBuildState): this;
  59671. }
  59672. }
  59673. declare module BABYLON {
  59674. /**
  59675. * Block used to step a value
  59676. */
  59677. export class StepBlock extends NodeMaterialBlock {
  59678. /**
  59679. * Creates a new StepBlock
  59680. * @param name defines the block name
  59681. */
  59682. constructor(name: string);
  59683. /**
  59684. * Gets the current class name
  59685. * @returns the class name
  59686. */
  59687. getClassName(): string;
  59688. /**
  59689. * Gets the value operand input component
  59690. */
  59691. get value(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the edge operand input component
  59694. */
  59695. get edge(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the output component
  59698. */
  59699. get output(): NodeMaterialConnectionPoint;
  59700. protected _buildBlock(state: NodeMaterialBuildState): this;
  59701. }
  59702. }
  59703. declare module BABYLON {
  59704. /**
  59705. * Block used to get the opposite (1 - x) of a value
  59706. */
  59707. export class OneMinusBlock extends NodeMaterialBlock {
  59708. /**
  59709. * Creates a new OneMinusBlock
  59710. * @param name defines the block name
  59711. */
  59712. constructor(name: string);
  59713. /**
  59714. * Gets the current class name
  59715. * @returns the class name
  59716. */
  59717. getClassName(): string;
  59718. /**
  59719. * Gets the input component
  59720. */
  59721. get input(): NodeMaterialConnectionPoint;
  59722. /**
  59723. * Gets the output component
  59724. */
  59725. get output(): NodeMaterialConnectionPoint;
  59726. protected _buildBlock(state: NodeMaterialBuildState): this;
  59727. }
  59728. }
  59729. declare module BABYLON {
  59730. /**
  59731. * Block used to get the view direction
  59732. */
  59733. export class ViewDirectionBlock extends NodeMaterialBlock {
  59734. /**
  59735. * Creates a new ViewDirectionBlock
  59736. * @param name defines the block name
  59737. */
  59738. constructor(name: string);
  59739. /**
  59740. * Gets the current class name
  59741. * @returns the class name
  59742. */
  59743. getClassName(): string;
  59744. /**
  59745. * Gets the world position component
  59746. */
  59747. get worldPosition(): NodeMaterialConnectionPoint;
  59748. /**
  59749. * Gets the camera position component
  59750. */
  59751. get cameraPosition(): NodeMaterialConnectionPoint;
  59752. /**
  59753. * Gets the output component
  59754. */
  59755. get output(): NodeMaterialConnectionPoint;
  59756. autoConfigure(material: NodeMaterial): void;
  59757. protected _buildBlock(state: NodeMaterialBuildState): this;
  59758. }
  59759. }
  59760. declare module BABYLON {
  59761. /**
  59762. * Block used to compute fresnel value
  59763. */
  59764. export class FresnelBlock extends NodeMaterialBlock {
  59765. /**
  59766. * Create a new FresnelBlock
  59767. * @param name defines the block name
  59768. */
  59769. constructor(name: string);
  59770. /**
  59771. * Gets the current class name
  59772. * @returns the class name
  59773. */
  59774. getClassName(): string;
  59775. /**
  59776. * Gets the world normal input component
  59777. */
  59778. get worldNormal(): NodeMaterialConnectionPoint;
  59779. /**
  59780. * Gets the view direction input component
  59781. */
  59782. get viewDirection(): NodeMaterialConnectionPoint;
  59783. /**
  59784. * Gets the bias input component
  59785. */
  59786. get bias(): NodeMaterialConnectionPoint;
  59787. /**
  59788. * Gets the camera (or eye) position component
  59789. */
  59790. get power(): NodeMaterialConnectionPoint;
  59791. /**
  59792. * Gets the fresnel output component
  59793. */
  59794. get fresnel(): NodeMaterialConnectionPoint;
  59795. autoConfigure(material: NodeMaterial): void;
  59796. protected _buildBlock(state: NodeMaterialBuildState): this;
  59797. }
  59798. }
  59799. declare module BABYLON {
  59800. /**
  59801. * Block used to get the max of 2 values
  59802. */
  59803. export class MaxBlock extends NodeMaterialBlock {
  59804. /**
  59805. * Creates a new MaxBlock
  59806. * @param name defines the block name
  59807. */
  59808. constructor(name: string);
  59809. /**
  59810. * Gets the current class name
  59811. * @returns the class name
  59812. */
  59813. getClassName(): string;
  59814. /**
  59815. * Gets the left operand input component
  59816. */
  59817. get left(): NodeMaterialConnectionPoint;
  59818. /**
  59819. * Gets the right operand input component
  59820. */
  59821. get right(): NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the output component
  59824. */
  59825. get output(): NodeMaterialConnectionPoint;
  59826. protected _buildBlock(state: NodeMaterialBuildState): this;
  59827. }
  59828. }
  59829. declare module BABYLON {
  59830. /**
  59831. * Block used to get the min of 2 values
  59832. */
  59833. export class MinBlock extends NodeMaterialBlock {
  59834. /**
  59835. * Creates a new MinBlock
  59836. * @param name defines the block name
  59837. */
  59838. constructor(name: string);
  59839. /**
  59840. * Gets the current class name
  59841. * @returns the class name
  59842. */
  59843. getClassName(): string;
  59844. /**
  59845. * Gets the left operand input component
  59846. */
  59847. get left(): NodeMaterialConnectionPoint;
  59848. /**
  59849. * Gets the right operand input component
  59850. */
  59851. get right(): NodeMaterialConnectionPoint;
  59852. /**
  59853. * Gets the output component
  59854. */
  59855. get output(): NodeMaterialConnectionPoint;
  59856. protected _buildBlock(state: NodeMaterialBuildState): this;
  59857. }
  59858. }
  59859. declare module BABYLON {
  59860. /**
  59861. * Block used to get the distance between 2 values
  59862. */
  59863. export class DistanceBlock extends NodeMaterialBlock {
  59864. /**
  59865. * Creates a new DistanceBlock
  59866. * @param name defines the block name
  59867. */
  59868. constructor(name: string);
  59869. /**
  59870. * Gets the current class name
  59871. * @returns the class name
  59872. */
  59873. getClassName(): string;
  59874. /**
  59875. * Gets the left operand input component
  59876. */
  59877. get left(): NodeMaterialConnectionPoint;
  59878. /**
  59879. * Gets the right operand input component
  59880. */
  59881. get right(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the output component
  59884. */
  59885. get output(): NodeMaterialConnectionPoint;
  59886. protected _buildBlock(state: NodeMaterialBuildState): this;
  59887. }
  59888. }
  59889. declare module BABYLON {
  59890. /**
  59891. * Block used to get the length of a vector
  59892. */
  59893. export class LengthBlock extends NodeMaterialBlock {
  59894. /**
  59895. * Creates a new LengthBlock
  59896. * @param name defines the block name
  59897. */
  59898. constructor(name: string);
  59899. /**
  59900. * Gets the current class name
  59901. * @returns the class name
  59902. */
  59903. getClassName(): string;
  59904. /**
  59905. * Gets the value input component
  59906. */
  59907. get value(): NodeMaterialConnectionPoint;
  59908. /**
  59909. * Gets the output component
  59910. */
  59911. get output(): NodeMaterialConnectionPoint;
  59912. protected _buildBlock(state: NodeMaterialBuildState): this;
  59913. }
  59914. }
  59915. declare module BABYLON {
  59916. /**
  59917. * Block used to get negative version of a value (i.e. x * -1)
  59918. */
  59919. export class NegateBlock extends NodeMaterialBlock {
  59920. /**
  59921. * Creates a new NegateBlock
  59922. * @param name defines the block name
  59923. */
  59924. constructor(name: string);
  59925. /**
  59926. * Gets the current class name
  59927. * @returns the class name
  59928. */
  59929. getClassName(): string;
  59930. /**
  59931. * Gets the value input component
  59932. */
  59933. get value(): NodeMaterialConnectionPoint;
  59934. /**
  59935. * Gets the output component
  59936. */
  59937. get output(): NodeMaterialConnectionPoint;
  59938. protected _buildBlock(state: NodeMaterialBuildState): this;
  59939. }
  59940. }
  59941. declare module BABYLON {
  59942. /**
  59943. * Block used to get the value of the first parameter raised to the power of the second
  59944. */
  59945. export class PowBlock extends NodeMaterialBlock {
  59946. /**
  59947. * Creates a new PowBlock
  59948. * @param name defines the block name
  59949. */
  59950. constructor(name: string);
  59951. /**
  59952. * Gets the current class name
  59953. * @returns the class name
  59954. */
  59955. getClassName(): string;
  59956. /**
  59957. * Gets the value operand input component
  59958. */
  59959. get value(): NodeMaterialConnectionPoint;
  59960. /**
  59961. * Gets the power operand input component
  59962. */
  59963. get power(): NodeMaterialConnectionPoint;
  59964. /**
  59965. * Gets the output component
  59966. */
  59967. get output(): NodeMaterialConnectionPoint;
  59968. protected _buildBlock(state: NodeMaterialBuildState): this;
  59969. }
  59970. }
  59971. declare module BABYLON {
  59972. /**
  59973. * Block used to get a random number
  59974. */
  59975. export class RandomNumberBlock extends NodeMaterialBlock {
  59976. /**
  59977. * Creates a new RandomNumberBlock
  59978. * @param name defines the block name
  59979. */
  59980. constructor(name: string);
  59981. /**
  59982. * Gets the current class name
  59983. * @returns the class name
  59984. */
  59985. getClassName(): string;
  59986. /**
  59987. * Gets the seed input component
  59988. */
  59989. get seed(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the output component
  59992. */
  59993. get output(): NodeMaterialConnectionPoint;
  59994. protected _buildBlock(state: NodeMaterialBuildState): this;
  59995. }
  59996. }
  59997. declare module BABYLON {
  59998. /**
  59999. * Block used to compute arc tangent of 2 values
  60000. */
  60001. export class ArcTan2Block extends NodeMaterialBlock {
  60002. /**
  60003. * Creates a new ArcTan2Block
  60004. * @param name defines the block name
  60005. */
  60006. constructor(name: string);
  60007. /**
  60008. * Gets the current class name
  60009. * @returns the class name
  60010. */
  60011. getClassName(): string;
  60012. /**
  60013. * Gets the x operand input component
  60014. */
  60015. get x(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the y operand input component
  60018. */
  60019. get y(): NodeMaterialConnectionPoint;
  60020. /**
  60021. * Gets the output component
  60022. */
  60023. get output(): NodeMaterialConnectionPoint;
  60024. protected _buildBlock(state: NodeMaterialBuildState): this;
  60025. }
  60026. }
  60027. declare module BABYLON {
  60028. /**
  60029. * Block used to smooth step a value
  60030. */
  60031. export class SmoothStepBlock extends NodeMaterialBlock {
  60032. /**
  60033. * Creates a new SmoothStepBlock
  60034. * @param name defines the block name
  60035. */
  60036. constructor(name: string);
  60037. /**
  60038. * Gets the current class name
  60039. * @returns the class name
  60040. */
  60041. getClassName(): string;
  60042. /**
  60043. * Gets the value operand input component
  60044. */
  60045. get value(): NodeMaterialConnectionPoint;
  60046. /**
  60047. * Gets the first edge operand input component
  60048. */
  60049. get edge0(): NodeMaterialConnectionPoint;
  60050. /**
  60051. * Gets the second edge operand input component
  60052. */
  60053. get edge1(): NodeMaterialConnectionPoint;
  60054. /**
  60055. * Gets the output component
  60056. */
  60057. get output(): NodeMaterialConnectionPoint;
  60058. protected _buildBlock(state: NodeMaterialBuildState): this;
  60059. }
  60060. }
  60061. declare module BABYLON {
  60062. /**
  60063. * Block used to get the reciprocal (1 / x) of a value
  60064. */
  60065. export class ReciprocalBlock extends NodeMaterialBlock {
  60066. /**
  60067. * Creates a new ReciprocalBlock
  60068. * @param name defines the block name
  60069. */
  60070. constructor(name: string);
  60071. /**
  60072. * Gets the current class name
  60073. * @returns the class name
  60074. */
  60075. getClassName(): string;
  60076. /**
  60077. * Gets the input component
  60078. */
  60079. get input(): NodeMaterialConnectionPoint;
  60080. /**
  60081. * Gets the output component
  60082. */
  60083. get output(): NodeMaterialConnectionPoint;
  60084. protected _buildBlock(state: NodeMaterialBuildState): this;
  60085. }
  60086. }
  60087. declare module BABYLON {
  60088. /**
  60089. * Block used to replace a color by another one
  60090. */
  60091. export class ReplaceColorBlock extends NodeMaterialBlock {
  60092. /**
  60093. * Creates a new ReplaceColorBlock
  60094. * @param name defines the block name
  60095. */
  60096. constructor(name: string);
  60097. /**
  60098. * Gets the current class name
  60099. * @returns the class name
  60100. */
  60101. getClassName(): string;
  60102. /**
  60103. * Gets the value input component
  60104. */
  60105. get value(): NodeMaterialConnectionPoint;
  60106. /**
  60107. * Gets the reference input component
  60108. */
  60109. get reference(): NodeMaterialConnectionPoint;
  60110. /**
  60111. * Gets the distance input component
  60112. */
  60113. get distance(): NodeMaterialConnectionPoint;
  60114. /**
  60115. * Gets the replacement input component
  60116. */
  60117. get replacement(): NodeMaterialConnectionPoint;
  60118. /**
  60119. * Gets the output component
  60120. */
  60121. get output(): NodeMaterialConnectionPoint;
  60122. protected _buildBlock(state: NodeMaterialBuildState): this;
  60123. }
  60124. }
  60125. declare module BABYLON {
  60126. /**
  60127. * Block used to posterize a value
  60128. * @see https://en.wikipedia.org/wiki/Posterization
  60129. */
  60130. export class PosterizeBlock extends NodeMaterialBlock {
  60131. /**
  60132. * Creates a new PosterizeBlock
  60133. * @param name defines the block name
  60134. */
  60135. constructor(name: string);
  60136. /**
  60137. * Gets the current class name
  60138. * @returns the class name
  60139. */
  60140. getClassName(): string;
  60141. /**
  60142. * Gets the value input component
  60143. */
  60144. get value(): NodeMaterialConnectionPoint;
  60145. /**
  60146. * Gets the steps input component
  60147. */
  60148. get steps(): NodeMaterialConnectionPoint;
  60149. /**
  60150. * Gets the output component
  60151. */
  60152. get output(): NodeMaterialConnectionPoint;
  60153. protected _buildBlock(state: NodeMaterialBuildState): this;
  60154. }
  60155. }
  60156. declare module BABYLON {
  60157. /**
  60158. * Operations supported by the Wave block
  60159. */
  60160. export enum WaveBlockKind {
  60161. /** SawTooth */
  60162. SawTooth = 0,
  60163. /** Square */
  60164. Square = 1,
  60165. /** Triangle */
  60166. Triangle = 2
  60167. }
  60168. /**
  60169. * Block used to apply wave operation to floats
  60170. */
  60171. export class WaveBlock extends NodeMaterialBlock {
  60172. /**
  60173. * Gets or sets the kibnd of wave to be applied by the block
  60174. */
  60175. kind: WaveBlockKind;
  60176. /**
  60177. * Creates a new WaveBlock
  60178. * @param name defines the block name
  60179. */
  60180. constructor(name: string);
  60181. /**
  60182. * Gets the current class name
  60183. * @returns the class name
  60184. */
  60185. getClassName(): string;
  60186. /**
  60187. * Gets the input component
  60188. */
  60189. get input(): NodeMaterialConnectionPoint;
  60190. /**
  60191. * Gets the output component
  60192. */
  60193. get output(): NodeMaterialConnectionPoint;
  60194. protected _buildBlock(state: NodeMaterialBuildState): this;
  60195. serialize(): any;
  60196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60197. }
  60198. }
  60199. declare module BABYLON {
  60200. /**
  60201. * Class used to store a color step for the GradientBlock
  60202. */
  60203. export class GradientBlockColorStep {
  60204. /**
  60205. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60206. */
  60207. step: number;
  60208. /**
  60209. * Gets or sets the color associated with this step
  60210. */
  60211. color: Color3;
  60212. /**
  60213. * Creates a new GradientBlockColorStep
  60214. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60215. * @param color defines the color associated with this step
  60216. */
  60217. constructor(
  60218. /**
  60219. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60220. */
  60221. step: number,
  60222. /**
  60223. * Gets or sets the color associated with this step
  60224. */
  60225. color: Color3);
  60226. }
  60227. /**
  60228. * Block used to return a color from a gradient based on an input value between 0 and 1
  60229. */
  60230. export class GradientBlock extends NodeMaterialBlock {
  60231. /**
  60232. * Gets or sets the list of color steps
  60233. */
  60234. colorSteps: GradientBlockColorStep[];
  60235. /**
  60236. * Creates a new GradientBlock
  60237. * @param name defines the block name
  60238. */
  60239. constructor(name: string);
  60240. /**
  60241. * Gets the current class name
  60242. * @returns the class name
  60243. */
  60244. getClassName(): string;
  60245. /**
  60246. * Gets the gradient input component
  60247. */
  60248. get gradient(): NodeMaterialConnectionPoint;
  60249. /**
  60250. * Gets the output component
  60251. */
  60252. get output(): NodeMaterialConnectionPoint;
  60253. private _writeColorConstant;
  60254. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60255. serialize(): any;
  60256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60257. protected _dumpPropertiesCode(): string;
  60258. }
  60259. }
  60260. declare module BABYLON {
  60261. /**
  60262. * Block used to normalize lerp between 2 values
  60263. */
  60264. export class NLerpBlock extends NodeMaterialBlock {
  60265. /**
  60266. * Creates a new NLerpBlock
  60267. * @param name defines the block name
  60268. */
  60269. constructor(name: string);
  60270. /**
  60271. * Gets the current class name
  60272. * @returns the class name
  60273. */
  60274. getClassName(): string;
  60275. /**
  60276. * Gets the left operand input component
  60277. */
  60278. get left(): NodeMaterialConnectionPoint;
  60279. /**
  60280. * Gets the right operand input component
  60281. */
  60282. get right(): NodeMaterialConnectionPoint;
  60283. /**
  60284. * Gets the gradient operand input component
  60285. */
  60286. get gradient(): NodeMaterialConnectionPoint;
  60287. /**
  60288. * Gets the output component
  60289. */
  60290. get output(): NodeMaterialConnectionPoint;
  60291. protected _buildBlock(state: NodeMaterialBuildState): this;
  60292. }
  60293. }
  60294. declare module BABYLON {
  60295. /**
  60296. * block used to Generate a Worley Noise 3D Noise Pattern
  60297. */
  60298. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60299. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60300. manhattanDistance: boolean;
  60301. /**
  60302. * Creates a new WorleyNoise3DBlock
  60303. * @param name defines the block name
  60304. */
  60305. constructor(name: string);
  60306. /**
  60307. * Gets the current class name
  60308. * @returns the class name
  60309. */
  60310. getClassName(): string;
  60311. /**
  60312. * Gets the seed input component
  60313. */
  60314. get seed(): NodeMaterialConnectionPoint;
  60315. /**
  60316. * Gets the jitter input component
  60317. */
  60318. get jitter(): NodeMaterialConnectionPoint;
  60319. /**
  60320. * Gets the output component
  60321. */
  60322. get output(): NodeMaterialConnectionPoint;
  60323. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60324. /**
  60325. * Exposes the properties to the UI?
  60326. */
  60327. protected _dumpPropertiesCode(): string;
  60328. /**
  60329. * Exposes the properties to the Seralize?
  60330. */
  60331. serialize(): any;
  60332. /**
  60333. * Exposes the properties to the deseralize?
  60334. */
  60335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60336. }
  60337. }
  60338. declare module BABYLON {
  60339. /**
  60340. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60341. */
  60342. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60343. /**
  60344. * Creates a new SimplexPerlin3DBlock
  60345. * @param name defines the block name
  60346. */
  60347. constructor(name: string);
  60348. /**
  60349. * Gets the current class name
  60350. * @returns the class name
  60351. */
  60352. getClassName(): string;
  60353. /**
  60354. * Gets the seed operand input component
  60355. */
  60356. get seed(): NodeMaterialConnectionPoint;
  60357. /**
  60358. * Gets the output component
  60359. */
  60360. get output(): NodeMaterialConnectionPoint;
  60361. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60362. }
  60363. }
  60364. declare module BABYLON {
  60365. /**
  60366. * Block used to blend normals
  60367. */
  60368. export class NormalBlendBlock extends NodeMaterialBlock {
  60369. /**
  60370. * Creates a new NormalBlendBlock
  60371. * @param name defines the block name
  60372. */
  60373. constructor(name: string);
  60374. /**
  60375. * Gets the current class name
  60376. * @returns the class name
  60377. */
  60378. getClassName(): string;
  60379. /**
  60380. * Gets the first input component
  60381. */
  60382. get normalMap0(): NodeMaterialConnectionPoint;
  60383. /**
  60384. * Gets the second input component
  60385. */
  60386. get normalMap1(): NodeMaterialConnectionPoint;
  60387. /**
  60388. * Gets the output component
  60389. */
  60390. get output(): NodeMaterialConnectionPoint;
  60391. protected _buildBlock(state: NodeMaterialBuildState): this;
  60392. }
  60393. }
  60394. declare module BABYLON {
  60395. /**
  60396. * Block used to rotate a 2d vector by a given angle
  60397. */
  60398. export class Rotate2dBlock extends NodeMaterialBlock {
  60399. /**
  60400. * Creates a new Rotate2dBlock
  60401. * @param name defines the block name
  60402. */
  60403. constructor(name: string);
  60404. /**
  60405. * Gets the current class name
  60406. * @returns the class name
  60407. */
  60408. getClassName(): string;
  60409. /**
  60410. * Gets the input vector
  60411. */
  60412. get input(): NodeMaterialConnectionPoint;
  60413. /**
  60414. * Gets the input angle
  60415. */
  60416. get angle(): NodeMaterialConnectionPoint;
  60417. /**
  60418. * Gets the output component
  60419. */
  60420. get output(): NodeMaterialConnectionPoint;
  60421. autoConfigure(material: NodeMaterial): void;
  60422. protected _buildBlock(state: NodeMaterialBuildState): this;
  60423. }
  60424. }
  60425. declare module BABYLON {
  60426. /**
  60427. * Block used to get the reflected vector from a direction and a normal
  60428. */
  60429. export class ReflectBlock extends NodeMaterialBlock {
  60430. /**
  60431. * Creates a new ReflectBlock
  60432. * @param name defines the block name
  60433. */
  60434. constructor(name: string);
  60435. /**
  60436. * Gets the current class name
  60437. * @returns the class name
  60438. */
  60439. getClassName(): string;
  60440. /**
  60441. * Gets the incident component
  60442. */
  60443. get incident(): NodeMaterialConnectionPoint;
  60444. /**
  60445. * Gets the normal component
  60446. */
  60447. get normal(): NodeMaterialConnectionPoint;
  60448. /**
  60449. * Gets the output component
  60450. */
  60451. get output(): NodeMaterialConnectionPoint;
  60452. protected _buildBlock(state: NodeMaterialBuildState): this;
  60453. }
  60454. }
  60455. declare module BABYLON {
  60456. /**
  60457. * Block used to get the refracted vector from a direction and a normal
  60458. */
  60459. export class RefractBlock extends NodeMaterialBlock {
  60460. /**
  60461. * Creates a new RefractBlock
  60462. * @param name defines the block name
  60463. */
  60464. constructor(name: string);
  60465. /**
  60466. * Gets the current class name
  60467. * @returns the class name
  60468. */
  60469. getClassName(): string;
  60470. /**
  60471. * Gets the incident component
  60472. */
  60473. get incident(): NodeMaterialConnectionPoint;
  60474. /**
  60475. * Gets the normal component
  60476. */
  60477. get normal(): NodeMaterialConnectionPoint;
  60478. /**
  60479. * Gets the index of refraction component
  60480. */
  60481. get ior(): NodeMaterialConnectionPoint;
  60482. /**
  60483. * Gets the output component
  60484. */
  60485. get output(): NodeMaterialConnectionPoint;
  60486. protected _buildBlock(state: NodeMaterialBuildState): this;
  60487. }
  60488. }
  60489. declare module BABYLON {
  60490. /**
  60491. * Block used to desaturate a color
  60492. */
  60493. export class DesaturateBlock extends NodeMaterialBlock {
  60494. /**
  60495. * Creates a new DesaturateBlock
  60496. * @param name defines the block name
  60497. */
  60498. constructor(name: string);
  60499. /**
  60500. * Gets the current class name
  60501. * @returns the class name
  60502. */
  60503. getClassName(): string;
  60504. /**
  60505. * Gets the color operand input component
  60506. */
  60507. get color(): NodeMaterialConnectionPoint;
  60508. /**
  60509. * Gets the level operand input component
  60510. */
  60511. get level(): NodeMaterialConnectionPoint;
  60512. /**
  60513. * Gets the output component
  60514. */
  60515. get output(): NodeMaterialConnectionPoint;
  60516. protected _buildBlock(state: NodeMaterialBuildState): this;
  60517. }
  60518. }
  60519. declare module BABYLON {
  60520. /**
  60521. * Effect Render Options
  60522. */
  60523. export interface IEffectRendererOptions {
  60524. /**
  60525. * Defines the vertices positions.
  60526. */
  60527. positions?: number[];
  60528. /**
  60529. * Defines the indices.
  60530. */
  60531. indices?: number[];
  60532. }
  60533. /**
  60534. * Helper class to render one or more effects
  60535. */
  60536. export class EffectRenderer {
  60537. private engine;
  60538. private static _DefaultOptions;
  60539. private _vertexBuffers;
  60540. private _indexBuffer;
  60541. private _ringBufferIndex;
  60542. private _ringScreenBuffer;
  60543. private _fullscreenViewport;
  60544. private _getNextFrameBuffer;
  60545. /**
  60546. * Creates an effect renderer
  60547. * @param engine the engine to use for rendering
  60548. * @param options defines the options of the effect renderer
  60549. */
  60550. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60551. /**
  60552. * Sets the current viewport in normalized coordinates 0-1
  60553. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60554. */
  60555. setViewport(viewport?: Viewport): void;
  60556. /**
  60557. * Binds the embedded attributes buffer to the effect.
  60558. * @param effect Defines the effect to bind the attributes for
  60559. */
  60560. bindBuffers(effect: Effect): void;
  60561. /**
  60562. * Sets the current effect wrapper to use during draw.
  60563. * The effect needs to be ready before calling this api.
  60564. * This also sets the default full screen position attribute.
  60565. * @param effectWrapper Defines the effect to draw with
  60566. */
  60567. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60568. /**
  60569. * Draws a full screen quad.
  60570. */
  60571. draw(): void;
  60572. /**
  60573. * renders one or more effects to a specified texture
  60574. * @param effectWrappers list of effects to renderer
  60575. * @param outputTexture texture to draw to, if null it will render to the screen
  60576. */
  60577. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60578. /**
  60579. * Disposes of the effect renderer
  60580. */
  60581. dispose(): void;
  60582. }
  60583. /**
  60584. * Options to create an EffectWrapper
  60585. */
  60586. interface EffectWrapperCreationOptions {
  60587. /**
  60588. * Engine to use to create the effect
  60589. */
  60590. engine: ThinEngine;
  60591. /**
  60592. * Fragment shader for the effect
  60593. */
  60594. fragmentShader: string;
  60595. /**
  60596. * Vertex shader for the effect
  60597. */
  60598. vertexShader?: string;
  60599. /**
  60600. * Attributes to use in the shader
  60601. */
  60602. attributeNames?: Array<string>;
  60603. /**
  60604. * Uniforms to use in the shader
  60605. */
  60606. uniformNames?: Array<string>;
  60607. /**
  60608. * Texture sampler names to use in the shader
  60609. */
  60610. samplerNames?: Array<string>;
  60611. /**
  60612. * The friendly name of the effect displayed in Spector.
  60613. */
  60614. name?: string;
  60615. }
  60616. /**
  60617. * Wraps an effect to be used for rendering
  60618. */
  60619. export class EffectWrapper {
  60620. /**
  60621. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60622. */
  60623. onApplyObservable: Observable<{}>;
  60624. /**
  60625. * The underlying effect
  60626. */
  60627. effect: Effect;
  60628. /**
  60629. * Creates an effect to be renderer
  60630. * @param creationOptions options to create the effect
  60631. */
  60632. constructor(creationOptions: EffectWrapperCreationOptions);
  60633. /**
  60634. * Disposes of the effect wrapper
  60635. */
  60636. dispose(): void;
  60637. }
  60638. }
  60639. declare module BABYLON {
  60640. /**
  60641. * Helper class to push actions to a pool of workers.
  60642. */
  60643. export class WorkerPool implements IDisposable {
  60644. private _workerInfos;
  60645. private _pendingActions;
  60646. /**
  60647. * Constructor
  60648. * @param workers Array of workers to use for actions
  60649. */
  60650. constructor(workers: Array<Worker>);
  60651. /**
  60652. * Terminates all workers and clears any pending actions.
  60653. */
  60654. dispose(): void;
  60655. /**
  60656. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60657. * pended until a worker has completed its action.
  60658. * @param action The action to perform. Call onComplete when the action is complete.
  60659. */
  60660. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60661. private _execute;
  60662. }
  60663. }
  60664. declare module BABYLON {
  60665. /**
  60666. * Configuration for Draco compression
  60667. */
  60668. export interface IDracoCompressionConfiguration {
  60669. /**
  60670. * Configuration for the decoder.
  60671. */
  60672. decoder: {
  60673. /**
  60674. * The url to the WebAssembly module.
  60675. */
  60676. wasmUrl?: string;
  60677. /**
  60678. * The url to the WebAssembly binary.
  60679. */
  60680. wasmBinaryUrl?: string;
  60681. /**
  60682. * The url to the fallback JavaScript module.
  60683. */
  60684. fallbackUrl?: string;
  60685. };
  60686. }
  60687. /**
  60688. * Draco compression (https://google.github.io/draco/)
  60689. *
  60690. * This class wraps the Draco module.
  60691. *
  60692. * **Encoder**
  60693. *
  60694. * The encoder is not currently implemented.
  60695. *
  60696. * **Decoder**
  60697. *
  60698. * 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.
  60699. *
  60700. * To update the configuration, use the following code:
  60701. * ```javascript
  60702. * DracoCompression.Configuration = {
  60703. * decoder: {
  60704. * wasmUrl: "<url to the WebAssembly library>",
  60705. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60706. * fallbackUrl: "<url to the fallback JavaScript library>",
  60707. * }
  60708. * };
  60709. * ```
  60710. *
  60711. * 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.
  60712. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60713. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60714. *
  60715. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60716. * ```javascript
  60717. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60718. * ```
  60719. *
  60720. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60721. */
  60722. export class DracoCompression implements IDisposable {
  60723. private _workerPoolPromise?;
  60724. private _decoderModulePromise?;
  60725. /**
  60726. * The configuration. Defaults to the following urls:
  60727. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60728. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60729. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60730. */
  60731. static Configuration: IDracoCompressionConfiguration;
  60732. /**
  60733. * Returns true if the decoder configuration is available.
  60734. */
  60735. static get DecoderAvailable(): boolean;
  60736. /**
  60737. * Default number of workers to create when creating the draco compression object.
  60738. */
  60739. static DefaultNumWorkers: number;
  60740. private static GetDefaultNumWorkers;
  60741. private static _Default;
  60742. /**
  60743. * Default instance for the draco compression object.
  60744. */
  60745. static get Default(): DracoCompression;
  60746. /**
  60747. * Constructor
  60748. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60749. */
  60750. constructor(numWorkers?: number);
  60751. /**
  60752. * Stop all async operations and release resources.
  60753. */
  60754. dispose(): void;
  60755. /**
  60756. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60757. * @returns a promise that resolves when ready
  60758. */
  60759. whenReadyAsync(): Promise<void>;
  60760. /**
  60761. * Decode Draco compressed mesh data to vertex data.
  60762. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60763. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60764. * @returns A promise that resolves with the decoded vertex data
  60765. */
  60766. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60767. [kind: string]: number;
  60768. }): Promise<VertexData>;
  60769. }
  60770. }
  60771. declare module BABYLON {
  60772. /**
  60773. * Class for building Constructive Solid Geometry
  60774. */
  60775. export class CSG {
  60776. private polygons;
  60777. /**
  60778. * The world matrix
  60779. */
  60780. matrix: Matrix;
  60781. /**
  60782. * Stores the position
  60783. */
  60784. position: Vector3;
  60785. /**
  60786. * Stores the rotation
  60787. */
  60788. rotation: Vector3;
  60789. /**
  60790. * Stores the rotation quaternion
  60791. */
  60792. rotationQuaternion: Nullable<Quaternion>;
  60793. /**
  60794. * Stores the scaling vector
  60795. */
  60796. scaling: Vector3;
  60797. /**
  60798. * Convert the Mesh to CSG
  60799. * @param mesh The Mesh to convert to CSG
  60800. * @returns A new CSG from the Mesh
  60801. */
  60802. static FromMesh(mesh: Mesh): CSG;
  60803. /**
  60804. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60805. * @param polygons Polygons used to construct a CSG solid
  60806. */
  60807. private static FromPolygons;
  60808. /**
  60809. * Clones, or makes a deep copy, of the CSG
  60810. * @returns A new CSG
  60811. */
  60812. clone(): CSG;
  60813. /**
  60814. * Unions this CSG with another CSG
  60815. * @param csg The CSG to union against this CSG
  60816. * @returns The unioned CSG
  60817. */
  60818. union(csg: CSG): CSG;
  60819. /**
  60820. * Unions this CSG with another CSG in place
  60821. * @param csg The CSG to union against this CSG
  60822. */
  60823. unionInPlace(csg: CSG): void;
  60824. /**
  60825. * Subtracts this CSG with another CSG
  60826. * @param csg The CSG to subtract against this CSG
  60827. * @returns A new CSG
  60828. */
  60829. subtract(csg: CSG): CSG;
  60830. /**
  60831. * Subtracts this CSG with another CSG in place
  60832. * @param csg The CSG to subtact against this CSG
  60833. */
  60834. subtractInPlace(csg: CSG): void;
  60835. /**
  60836. * Intersect this CSG with another CSG
  60837. * @param csg The CSG to intersect against this CSG
  60838. * @returns A new CSG
  60839. */
  60840. intersect(csg: CSG): CSG;
  60841. /**
  60842. * Intersects this CSG with another CSG in place
  60843. * @param csg The CSG to intersect against this CSG
  60844. */
  60845. intersectInPlace(csg: CSG): void;
  60846. /**
  60847. * Return a new CSG solid with solid and empty space switched. This solid is
  60848. * not modified.
  60849. * @returns A new CSG solid with solid and empty space switched
  60850. */
  60851. inverse(): CSG;
  60852. /**
  60853. * Inverses the CSG in place
  60854. */
  60855. inverseInPlace(): void;
  60856. /**
  60857. * This is used to keep meshes transformations so they can be restored
  60858. * when we build back a Babylon Mesh
  60859. * NB : All CSG operations are performed in world coordinates
  60860. * @param csg The CSG to copy the transform attributes from
  60861. * @returns This CSG
  60862. */
  60863. copyTransformAttributes(csg: CSG): CSG;
  60864. /**
  60865. * Build Raw mesh from CSG
  60866. * Coordinates here are in world space
  60867. * @param name The name of the mesh geometry
  60868. * @param scene The Scene
  60869. * @param keepSubMeshes Specifies if the submeshes should be kept
  60870. * @returns A new Mesh
  60871. */
  60872. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60873. /**
  60874. * Build Mesh from CSG taking material and transforms into account
  60875. * @param name The name of the Mesh
  60876. * @param material The material of the Mesh
  60877. * @param scene The Scene
  60878. * @param keepSubMeshes Specifies if submeshes should be kept
  60879. * @returns The new Mesh
  60880. */
  60881. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60882. }
  60883. }
  60884. declare module BABYLON {
  60885. /**
  60886. * Class used to create a trail following a mesh
  60887. */
  60888. export class TrailMesh extends Mesh {
  60889. private _generator;
  60890. private _autoStart;
  60891. private _running;
  60892. private _diameter;
  60893. private _length;
  60894. private _sectionPolygonPointsCount;
  60895. private _sectionVectors;
  60896. private _sectionNormalVectors;
  60897. private _beforeRenderObserver;
  60898. /**
  60899. * @constructor
  60900. * @param name The value used by scene.getMeshByName() to do a lookup.
  60901. * @param generator The mesh or transform node to generate a trail.
  60902. * @param scene The scene to add this mesh to.
  60903. * @param diameter Diameter of trailing mesh. Default is 1.
  60904. * @param length Length of trailing mesh. Default is 60.
  60905. * @param autoStart Automatically start trailing mesh. Default true.
  60906. */
  60907. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60908. /**
  60909. * "TrailMesh"
  60910. * @returns "TrailMesh"
  60911. */
  60912. getClassName(): string;
  60913. private _createMesh;
  60914. /**
  60915. * Start trailing mesh.
  60916. */
  60917. start(): void;
  60918. /**
  60919. * Stop trailing mesh.
  60920. */
  60921. stop(): void;
  60922. /**
  60923. * Update trailing mesh geometry.
  60924. */
  60925. update(): void;
  60926. /**
  60927. * Returns a new TrailMesh object.
  60928. * @param name is a string, the name given to the new mesh
  60929. * @param newGenerator use new generator object for cloned trail mesh
  60930. * @returns a new mesh
  60931. */
  60932. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60933. /**
  60934. * Serializes this trail mesh
  60935. * @param serializationObject object to write serialization to
  60936. */
  60937. serialize(serializationObject: any): void;
  60938. /**
  60939. * Parses a serialized trail mesh
  60940. * @param parsedMesh the serialized mesh
  60941. * @param scene the scene to create the trail mesh in
  60942. * @returns the created trail mesh
  60943. */
  60944. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60945. }
  60946. }
  60947. declare module BABYLON {
  60948. /**
  60949. * Class containing static functions to help procedurally build meshes
  60950. */
  60951. export class TiledBoxBuilder {
  60952. /**
  60953. * Creates a box mesh
  60954. * 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)
  60955. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60957. * * 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
  60958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60959. * @param name defines the name of the mesh
  60960. * @param options defines the options used to create the mesh
  60961. * @param scene defines the hosting scene
  60962. * @returns the box mesh
  60963. */
  60964. static CreateTiledBox(name: string, options: {
  60965. pattern?: number;
  60966. width?: number;
  60967. height?: number;
  60968. depth?: number;
  60969. tileSize?: number;
  60970. tileWidth?: number;
  60971. tileHeight?: number;
  60972. alignHorizontal?: number;
  60973. alignVertical?: number;
  60974. faceUV?: Vector4[];
  60975. faceColors?: Color4[];
  60976. sideOrientation?: number;
  60977. updatable?: boolean;
  60978. }, scene?: Nullable<Scene>): Mesh;
  60979. }
  60980. }
  60981. declare module BABYLON {
  60982. /**
  60983. * Class containing static functions to help procedurally build meshes
  60984. */
  60985. export class TorusKnotBuilder {
  60986. /**
  60987. * Creates a torus knot mesh
  60988. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60989. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60990. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60991. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60993. * * 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
  60994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60995. * @param name defines the name of the mesh
  60996. * @param options defines the options used to create the mesh
  60997. * @param scene defines the hosting scene
  60998. * @returns the torus knot mesh
  60999. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61000. */
  61001. static CreateTorusKnot(name: string, options: {
  61002. radius?: number;
  61003. tube?: number;
  61004. radialSegments?: number;
  61005. tubularSegments?: number;
  61006. p?: number;
  61007. q?: number;
  61008. updatable?: boolean;
  61009. sideOrientation?: number;
  61010. frontUVs?: Vector4;
  61011. backUVs?: Vector4;
  61012. }, scene: any): Mesh;
  61013. }
  61014. }
  61015. declare module BABYLON {
  61016. /**
  61017. * Polygon
  61018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61019. */
  61020. export class Polygon {
  61021. /**
  61022. * Creates a rectangle
  61023. * @param xmin bottom X coord
  61024. * @param ymin bottom Y coord
  61025. * @param xmax top X coord
  61026. * @param ymax top Y coord
  61027. * @returns points that make the resulting rectation
  61028. */
  61029. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61030. /**
  61031. * Creates a circle
  61032. * @param radius radius of circle
  61033. * @param cx scale in x
  61034. * @param cy scale in y
  61035. * @param numberOfSides number of sides that make up the circle
  61036. * @returns points that make the resulting circle
  61037. */
  61038. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61039. /**
  61040. * Creates a polygon from input string
  61041. * @param input Input polygon data
  61042. * @returns the parsed points
  61043. */
  61044. static Parse(input: string): Vector2[];
  61045. /**
  61046. * Starts building a polygon from x and y coordinates
  61047. * @param x x coordinate
  61048. * @param y y coordinate
  61049. * @returns the started path2
  61050. */
  61051. static StartingAt(x: number, y: number): Path2;
  61052. }
  61053. /**
  61054. * Builds a polygon
  61055. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61056. */
  61057. export class PolygonMeshBuilder {
  61058. private _points;
  61059. private _outlinepoints;
  61060. private _holes;
  61061. private _name;
  61062. private _scene;
  61063. private _epoints;
  61064. private _eholes;
  61065. private _addToepoint;
  61066. /**
  61067. * Babylon reference to the earcut plugin.
  61068. */
  61069. bjsEarcut: any;
  61070. /**
  61071. * Creates a PolygonMeshBuilder
  61072. * @param name name of the builder
  61073. * @param contours Path of the polygon
  61074. * @param scene scene to add to when creating the mesh
  61075. * @param earcutInjection can be used to inject your own earcut reference
  61076. */
  61077. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61078. /**
  61079. * Adds a whole within the polygon
  61080. * @param hole Array of points defining the hole
  61081. * @returns this
  61082. */
  61083. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61084. /**
  61085. * Creates the polygon
  61086. * @param updatable If the mesh should be updatable
  61087. * @param depth The depth of the mesh created
  61088. * @returns the created mesh
  61089. */
  61090. build(updatable?: boolean, depth?: number): Mesh;
  61091. /**
  61092. * Creates the polygon
  61093. * @param depth The depth of the mesh created
  61094. * @returns the created VertexData
  61095. */
  61096. buildVertexData(depth?: number): VertexData;
  61097. /**
  61098. * Adds a side to the polygon
  61099. * @param positions points that make the polygon
  61100. * @param normals normals of the polygon
  61101. * @param uvs uvs of the polygon
  61102. * @param indices indices of the polygon
  61103. * @param bounds bounds of the polygon
  61104. * @param points points of the polygon
  61105. * @param depth depth of the polygon
  61106. * @param flip flip of the polygon
  61107. */
  61108. private addSide;
  61109. }
  61110. }
  61111. declare module BABYLON {
  61112. /**
  61113. * Class containing static functions to help procedurally build meshes
  61114. */
  61115. export class PolygonBuilder {
  61116. /**
  61117. * Creates a polygon mesh
  61118. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61119. * * 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
  61120. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61122. * * 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)
  61123. * * Remember you can only change the shape positions, not their number when updating a polygon
  61124. * @param name defines the name of the mesh
  61125. * @param options defines the options used to create the mesh
  61126. * @param scene defines the hosting scene
  61127. * @param earcutInjection can be used to inject your own earcut reference
  61128. * @returns the polygon mesh
  61129. */
  61130. static CreatePolygon(name: string, options: {
  61131. shape: Vector3[];
  61132. holes?: Vector3[][];
  61133. depth?: number;
  61134. faceUV?: Vector4[];
  61135. faceColors?: Color4[];
  61136. updatable?: boolean;
  61137. sideOrientation?: number;
  61138. frontUVs?: Vector4;
  61139. backUVs?: Vector4;
  61140. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61141. /**
  61142. * Creates an extruded polygon mesh, with depth in the Y direction.
  61143. * * 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)
  61144. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61145. * @param name defines the name of the mesh
  61146. * @param options defines the options used to create the mesh
  61147. * @param scene defines the hosting scene
  61148. * @param earcutInjection can be used to inject your own earcut reference
  61149. * @returns the polygon mesh
  61150. */
  61151. static ExtrudePolygon(name: string, options: {
  61152. shape: Vector3[];
  61153. holes?: Vector3[][];
  61154. depth?: number;
  61155. faceUV?: Vector4[];
  61156. faceColors?: Color4[];
  61157. updatable?: boolean;
  61158. sideOrientation?: number;
  61159. frontUVs?: Vector4;
  61160. backUVs?: Vector4;
  61161. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61162. }
  61163. }
  61164. declare module BABYLON {
  61165. /**
  61166. * Class containing static functions to help procedurally build meshes
  61167. */
  61168. export class LatheBuilder {
  61169. /**
  61170. * Creates lathe mesh.
  61171. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61172. * * 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
  61173. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61174. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61175. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61176. * * 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
  61177. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61178. * * 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
  61179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61180. * * 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
  61181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61183. * @param name defines the name of the mesh
  61184. * @param options defines the options used to create the mesh
  61185. * @param scene defines the hosting scene
  61186. * @returns the lathe mesh
  61187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61188. */
  61189. static CreateLathe(name: string, options: {
  61190. shape: Vector3[];
  61191. radius?: number;
  61192. tessellation?: number;
  61193. clip?: number;
  61194. arc?: number;
  61195. closed?: boolean;
  61196. updatable?: boolean;
  61197. sideOrientation?: number;
  61198. frontUVs?: Vector4;
  61199. backUVs?: Vector4;
  61200. cap?: number;
  61201. invertUV?: boolean;
  61202. }, scene?: Nullable<Scene>): Mesh;
  61203. }
  61204. }
  61205. declare module BABYLON {
  61206. /**
  61207. * Class containing static functions to help procedurally build meshes
  61208. */
  61209. export class TiledPlaneBuilder {
  61210. /**
  61211. * Creates a tiled plane mesh
  61212. * * The parameter `pattern` will, depending on value, do nothing or
  61213. * * * flip (reflect about central vertical) alternate tiles across and up
  61214. * * * flip every tile on alternate rows
  61215. * * * rotate (180 degs) alternate tiles across and up
  61216. * * * rotate every tile on alternate rows
  61217. * * * flip and rotate alternate tiles across and up
  61218. * * * flip and rotate every tile on alternate rows
  61219. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61220. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61221. * * 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
  61222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61223. * * 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)
  61224. * * 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)
  61225. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61226. * @param name defines the name of the mesh
  61227. * @param options defines the options used to create the mesh
  61228. * @param scene defines the hosting scene
  61229. * @returns the box mesh
  61230. */
  61231. static CreateTiledPlane(name: string, options: {
  61232. pattern?: number;
  61233. tileSize?: number;
  61234. tileWidth?: number;
  61235. tileHeight?: number;
  61236. size?: number;
  61237. width?: number;
  61238. height?: number;
  61239. alignHorizontal?: number;
  61240. alignVertical?: number;
  61241. sideOrientation?: number;
  61242. frontUVs?: Vector4;
  61243. backUVs?: Vector4;
  61244. updatable?: boolean;
  61245. }, scene?: Nullable<Scene>): Mesh;
  61246. }
  61247. }
  61248. declare module BABYLON {
  61249. /**
  61250. * Class containing static functions to help procedurally build meshes
  61251. */
  61252. export class TubeBuilder {
  61253. /**
  61254. * Creates a tube mesh.
  61255. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61256. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61257. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61258. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61259. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61260. * * 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)
  61261. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61262. * * 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
  61263. * * 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
  61264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61265. * * 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
  61266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61268. * @param name defines the name of the mesh
  61269. * @param options defines the options used to create the mesh
  61270. * @param scene defines the hosting scene
  61271. * @returns the tube mesh
  61272. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61273. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61274. */
  61275. static CreateTube(name: string, options: {
  61276. path: Vector3[];
  61277. radius?: number;
  61278. tessellation?: number;
  61279. radiusFunction?: {
  61280. (i: number, distance: number): number;
  61281. };
  61282. cap?: number;
  61283. arc?: number;
  61284. updatable?: boolean;
  61285. sideOrientation?: number;
  61286. frontUVs?: Vector4;
  61287. backUVs?: Vector4;
  61288. instance?: Mesh;
  61289. invertUV?: boolean;
  61290. }, scene?: Nullable<Scene>): Mesh;
  61291. }
  61292. }
  61293. declare module BABYLON {
  61294. /**
  61295. * Class containing static functions to help procedurally build meshes
  61296. */
  61297. export class IcoSphereBuilder {
  61298. /**
  61299. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61300. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61301. * * 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`)
  61302. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61303. * * 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
  61304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61305. * * 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
  61306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61307. * @param name defines the name of the mesh
  61308. * @param options defines the options used to create the mesh
  61309. * @param scene defines the hosting scene
  61310. * @returns the icosahedron mesh
  61311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61312. */
  61313. static CreateIcoSphere(name: string, options: {
  61314. radius?: number;
  61315. radiusX?: number;
  61316. radiusY?: number;
  61317. radiusZ?: number;
  61318. flat?: boolean;
  61319. subdivisions?: number;
  61320. sideOrientation?: number;
  61321. frontUVs?: Vector4;
  61322. backUVs?: Vector4;
  61323. updatable?: boolean;
  61324. }, scene?: Nullable<Scene>): Mesh;
  61325. }
  61326. }
  61327. declare module BABYLON {
  61328. /**
  61329. * Class containing static functions to help procedurally build meshes
  61330. */
  61331. export class DecalBuilder {
  61332. /**
  61333. * Creates a decal mesh.
  61334. * 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
  61335. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61336. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61337. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61338. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61339. * @param name defines the name of the mesh
  61340. * @param sourceMesh defines the mesh where the decal must be applied
  61341. * @param options defines the options used to create the mesh
  61342. * @param scene defines the hosting scene
  61343. * @returns the decal mesh
  61344. * @see https://doc.babylonjs.com/how_to/decals
  61345. */
  61346. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61347. position?: Vector3;
  61348. normal?: Vector3;
  61349. size?: Vector3;
  61350. angle?: number;
  61351. }): Mesh;
  61352. }
  61353. }
  61354. declare module BABYLON {
  61355. /**
  61356. * Class containing static functions to help procedurally build meshes
  61357. */
  61358. export class MeshBuilder {
  61359. /**
  61360. * Creates a box mesh
  61361. * * The parameter `size` sets the size (float) of each box side (default 1)
  61362. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61363. * * 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)
  61364. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61366. * * 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
  61367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61368. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61369. * @param name defines the name of the mesh
  61370. * @param options defines the options used to create the mesh
  61371. * @param scene defines the hosting scene
  61372. * @returns the box mesh
  61373. */
  61374. static CreateBox(name: string, options: {
  61375. size?: number;
  61376. width?: number;
  61377. height?: number;
  61378. depth?: number;
  61379. faceUV?: Vector4[];
  61380. faceColors?: Color4[];
  61381. sideOrientation?: number;
  61382. frontUVs?: Vector4;
  61383. backUVs?: Vector4;
  61384. wrap?: boolean;
  61385. topBaseAt?: number;
  61386. bottomBaseAt?: number;
  61387. updatable?: boolean;
  61388. }, scene?: Nullable<Scene>): Mesh;
  61389. /**
  61390. * Creates a tiled box mesh
  61391. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61393. * @param name defines the name of the mesh
  61394. * @param options defines the options used to create the mesh
  61395. * @param scene defines the hosting scene
  61396. * @returns the tiled box mesh
  61397. */
  61398. static CreateTiledBox(name: string, options: {
  61399. pattern?: number;
  61400. size?: number;
  61401. width?: number;
  61402. height?: number;
  61403. depth: number;
  61404. tileSize?: number;
  61405. tileWidth?: number;
  61406. tileHeight?: number;
  61407. faceUV?: Vector4[];
  61408. faceColors?: Color4[];
  61409. alignHorizontal?: number;
  61410. alignVertical?: number;
  61411. sideOrientation?: number;
  61412. updatable?: boolean;
  61413. }, scene?: Nullable<Scene>): Mesh;
  61414. /**
  61415. * Creates a sphere mesh
  61416. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61417. * * 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`)
  61418. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61419. * * 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
  61420. * * 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)
  61421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61422. * * 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
  61423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61424. * @param name defines the name of the mesh
  61425. * @param options defines the options used to create the mesh
  61426. * @param scene defines the hosting scene
  61427. * @returns the sphere mesh
  61428. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61429. */
  61430. static CreateSphere(name: string, options: {
  61431. segments?: number;
  61432. diameter?: number;
  61433. diameterX?: number;
  61434. diameterY?: number;
  61435. diameterZ?: number;
  61436. arc?: number;
  61437. slice?: number;
  61438. sideOrientation?: number;
  61439. frontUVs?: Vector4;
  61440. backUVs?: Vector4;
  61441. updatable?: boolean;
  61442. }, scene?: Nullable<Scene>): Mesh;
  61443. /**
  61444. * Creates a plane polygonal mesh. By default, this is a disc
  61445. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61446. * * 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
  61447. * * 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
  61448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61449. * * 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
  61450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61451. * @param name defines the name of the mesh
  61452. * @param options defines the options used to create the mesh
  61453. * @param scene defines the hosting scene
  61454. * @returns the plane polygonal mesh
  61455. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61456. */
  61457. static CreateDisc(name: string, options: {
  61458. radius?: number;
  61459. tessellation?: number;
  61460. arc?: number;
  61461. updatable?: boolean;
  61462. sideOrientation?: number;
  61463. frontUVs?: Vector4;
  61464. backUVs?: Vector4;
  61465. }, scene?: Nullable<Scene>): Mesh;
  61466. /**
  61467. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61468. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61469. * * 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`)
  61470. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61471. * * 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
  61472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61473. * * 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
  61474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61475. * @param name defines the name of the mesh
  61476. * @param options defines the options used to create the mesh
  61477. * @param scene defines the hosting scene
  61478. * @returns the icosahedron mesh
  61479. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61480. */
  61481. static CreateIcoSphere(name: string, options: {
  61482. radius?: number;
  61483. radiusX?: number;
  61484. radiusY?: number;
  61485. radiusZ?: number;
  61486. flat?: boolean;
  61487. subdivisions?: number;
  61488. sideOrientation?: number;
  61489. frontUVs?: Vector4;
  61490. backUVs?: Vector4;
  61491. updatable?: boolean;
  61492. }, scene?: Nullable<Scene>): Mesh;
  61493. /**
  61494. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61495. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61496. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61497. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61498. * * 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
  61499. * * 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
  61500. * * 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
  61501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61502. * * 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
  61503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61504. * * 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
  61505. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61506. * * 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
  61507. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61509. * @param name defines the name of the mesh
  61510. * @param options defines the options used to create the mesh
  61511. * @param scene defines the hosting scene
  61512. * @returns the ribbon mesh
  61513. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61515. */
  61516. static CreateRibbon(name: string, options: {
  61517. pathArray: Vector3[][];
  61518. closeArray?: boolean;
  61519. closePath?: boolean;
  61520. offset?: number;
  61521. updatable?: boolean;
  61522. sideOrientation?: number;
  61523. frontUVs?: Vector4;
  61524. backUVs?: Vector4;
  61525. instance?: Mesh;
  61526. invertUV?: boolean;
  61527. uvs?: Vector2[];
  61528. colors?: Color4[];
  61529. }, scene?: Nullable<Scene>): Mesh;
  61530. /**
  61531. * Creates a cylinder or a cone mesh
  61532. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61533. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61534. * * 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.
  61535. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61536. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61537. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61538. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61539. * * 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).
  61540. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61541. * * 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).
  61542. * * 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
  61543. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61544. * * 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
  61545. * * 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.
  61546. * * If `enclose` is false, a ring surface is one element.
  61547. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61548. * * 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
  61549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61550. * * 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
  61551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61552. * @param name defines the name of the mesh
  61553. * @param options defines the options used to create the mesh
  61554. * @param scene defines the hosting scene
  61555. * @returns the cylinder mesh
  61556. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61557. */
  61558. static CreateCylinder(name: string, options: {
  61559. height?: number;
  61560. diameterTop?: number;
  61561. diameterBottom?: number;
  61562. diameter?: number;
  61563. tessellation?: number;
  61564. subdivisions?: number;
  61565. arc?: number;
  61566. faceColors?: Color4[];
  61567. faceUV?: Vector4[];
  61568. updatable?: boolean;
  61569. hasRings?: boolean;
  61570. enclose?: boolean;
  61571. cap?: number;
  61572. sideOrientation?: number;
  61573. frontUVs?: Vector4;
  61574. backUVs?: Vector4;
  61575. }, scene?: Nullable<Scene>): Mesh;
  61576. /**
  61577. * Creates a torus mesh
  61578. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61579. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61580. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61582. * * 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
  61583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61584. * @param name defines the name of the mesh
  61585. * @param options defines the options used to create the mesh
  61586. * @param scene defines the hosting scene
  61587. * @returns the torus mesh
  61588. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61589. */
  61590. static CreateTorus(name: string, options: {
  61591. diameter?: number;
  61592. thickness?: number;
  61593. tessellation?: number;
  61594. updatable?: boolean;
  61595. sideOrientation?: number;
  61596. frontUVs?: Vector4;
  61597. backUVs?: Vector4;
  61598. }, scene?: Nullable<Scene>): Mesh;
  61599. /**
  61600. * Creates a torus knot mesh
  61601. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61602. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61603. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61604. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61606. * * 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
  61607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61608. * @param name defines the name of the mesh
  61609. * @param options defines the options used to create the mesh
  61610. * @param scene defines the hosting scene
  61611. * @returns the torus knot mesh
  61612. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61613. */
  61614. static CreateTorusKnot(name: string, options: {
  61615. radius?: number;
  61616. tube?: number;
  61617. radialSegments?: number;
  61618. tubularSegments?: number;
  61619. p?: number;
  61620. q?: number;
  61621. updatable?: boolean;
  61622. sideOrientation?: number;
  61623. frontUVs?: Vector4;
  61624. backUVs?: Vector4;
  61625. }, scene?: Nullable<Scene>): Mesh;
  61626. /**
  61627. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61628. * * 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
  61629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61630. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61631. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61632. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61633. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61634. * * 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
  61635. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61638. * @param name defines the name of the new line system
  61639. * @param options defines the options used to create the line system
  61640. * @param scene defines the hosting scene
  61641. * @returns a new line system mesh
  61642. */
  61643. static CreateLineSystem(name: string, options: {
  61644. lines: Vector3[][];
  61645. updatable?: boolean;
  61646. instance?: Nullable<LinesMesh>;
  61647. colors?: Nullable<Color4[][]>;
  61648. useVertexAlpha?: boolean;
  61649. }, scene: Nullable<Scene>): LinesMesh;
  61650. /**
  61651. * Creates a line mesh
  61652. * 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
  61653. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61654. * * The parameter `points` is an array successive Vector3
  61655. * * 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
  61656. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61657. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61658. * * When updating an instance, remember that only point positions can change, not the number of points
  61659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61661. * @param name defines the name of the new line system
  61662. * @param options defines the options used to create the line system
  61663. * @param scene defines the hosting scene
  61664. * @returns a new line mesh
  61665. */
  61666. static CreateLines(name: string, options: {
  61667. points: Vector3[];
  61668. updatable?: boolean;
  61669. instance?: Nullable<LinesMesh>;
  61670. colors?: Color4[];
  61671. useVertexAlpha?: boolean;
  61672. }, scene?: Nullable<Scene>): LinesMesh;
  61673. /**
  61674. * Creates a dashed line mesh
  61675. * * 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
  61676. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61677. * * The parameter `points` is an array successive Vector3
  61678. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61679. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61680. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61681. * * 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
  61682. * * When updating an instance, remember that only point positions can change, not the number of points
  61683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61684. * @param name defines the name of the mesh
  61685. * @param options defines the options used to create the mesh
  61686. * @param scene defines the hosting scene
  61687. * @returns the dashed line mesh
  61688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61689. */
  61690. static CreateDashedLines(name: string, options: {
  61691. points: Vector3[];
  61692. dashSize?: number;
  61693. gapSize?: number;
  61694. dashNb?: number;
  61695. updatable?: boolean;
  61696. instance?: LinesMesh;
  61697. }, scene?: Nullable<Scene>): LinesMesh;
  61698. /**
  61699. * 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.
  61700. * * 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.
  61701. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61702. * * 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.
  61703. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61704. * * 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
  61705. * * 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
  61706. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61708. * * 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
  61709. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61711. * @param name defines the name of the mesh
  61712. * @param options defines the options used to create the mesh
  61713. * @param scene defines the hosting scene
  61714. * @returns the extruded shape mesh
  61715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61717. */
  61718. static ExtrudeShape(name: string, options: {
  61719. shape: Vector3[];
  61720. path: Vector3[];
  61721. scale?: number;
  61722. rotation?: number;
  61723. cap?: number;
  61724. updatable?: boolean;
  61725. sideOrientation?: number;
  61726. frontUVs?: Vector4;
  61727. backUVs?: Vector4;
  61728. instance?: Mesh;
  61729. invertUV?: boolean;
  61730. }, scene?: Nullable<Scene>): Mesh;
  61731. /**
  61732. * Creates an custom extruded shape mesh.
  61733. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61734. * * 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.
  61735. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61736. * * 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
  61737. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61738. * * 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
  61739. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61740. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61741. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61742. * * 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
  61743. * * 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
  61744. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61746. * * 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
  61747. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61749. * @param name defines the name of the mesh
  61750. * @param options defines the options used to create the mesh
  61751. * @param scene defines the hosting scene
  61752. * @returns the custom extruded shape mesh
  61753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61754. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61756. */
  61757. static ExtrudeShapeCustom(name: string, options: {
  61758. shape: Vector3[];
  61759. path: Vector3[];
  61760. scaleFunction?: any;
  61761. rotationFunction?: any;
  61762. ribbonCloseArray?: boolean;
  61763. ribbonClosePath?: boolean;
  61764. cap?: number;
  61765. updatable?: boolean;
  61766. sideOrientation?: number;
  61767. frontUVs?: Vector4;
  61768. backUVs?: Vector4;
  61769. instance?: Mesh;
  61770. invertUV?: boolean;
  61771. }, scene?: Nullable<Scene>): Mesh;
  61772. /**
  61773. * Creates lathe mesh.
  61774. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61775. * * 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
  61776. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61777. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61778. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61779. * * 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
  61780. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61781. * * 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
  61782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61783. * * 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
  61784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61786. * @param name defines the name of the mesh
  61787. * @param options defines the options used to create the mesh
  61788. * @param scene defines the hosting scene
  61789. * @returns the lathe mesh
  61790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61791. */
  61792. static CreateLathe(name: string, options: {
  61793. shape: Vector3[];
  61794. radius?: number;
  61795. tessellation?: number;
  61796. clip?: number;
  61797. arc?: number;
  61798. closed?: boolean;
  61799. updatable?: boolean;
  61800. sideOrientation?: number;
  61801. frontUVs?: Vector4;
  61802. backUVs?: Vector4;
  61803. cap?: number;
  61804. invertUV?: boolean;
  61805. }, scene?: Nullable<Scene>): Mesh;
  61806. /**
  61807. * Creates a tiled plane mesh
  61808. * * You can set a limited pattern arrangement with the tiles
  61809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61810. * * 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
  61811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61812. * @param name defines the name of the mesh
  61813. * @param options defines the options used to create the mesh
  61814. * @param scene defines the hosting scene
  61815. * @returns the plane mesh
  61816. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61817. */
  61818. static CreateTiledPlane(name: string, options: {
  61819. pattern?: number;
  61820. tileSize?: number;
  61821. tileWidth?: number;
  61822. tileHeight?: number;
  61823. size?: number;
  61824. width?: number;
  61825. height?: number;
  61826. alignHorizontal?: number;
  61827. alignVertical?: number;
  61828. sideOrientation?: number;
  61829. frontUVs?: Vector4;
  61830. backUVs?: Vector4;
  61831. updatable?: boolean;
  61832. }, scene?: Nullable<Scene>): Mesh;
  61833. /**
  61834. * Creates a plane mesh
  61835. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61836. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61837. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61839. * * 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
  61840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61841. * @param name defines the name of the mesh
  61842. * @param options defines the options used to create the mesh
  61843. * @param scene defines the hosting scene
  61844. * @returns the plane mesh
  61845. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61846. */
  61847. static CreatePlane(name: string, options: {
  61848. size?: number;
  61849. width?: number;
  61850. height?: number;
  61851. sideOrientation?: number;
  61852. frontUVs?: Vector4;
  61853. backUVs?: Vector4;
  61854. updatable?: boolean;
  61855. sourcePlane?: Plane;
  61856. }, scene?: Nullable<Scene>): Mesh;
  61857. /**
  61858. * Creates a ground mesh
  61859. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61860. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61862. * @param name defines the name of the mesh
  61863. * @param options defines the options used to create the mesh
  61864. * @param scene defines the hosting scene
  61865. * @returns the ground mesh
  61866. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61867. */
  61868. static CreateGround(name: string, options: {
  61869. width?: number;
  61870. height?: number;
  61871. subdivisions?: number;
  61872. subdivisionsX?: number;
  61873. subdivisionsY?: number;
  61874. updatable?: boolean;
  61875. }, scene?: Nullable<Scene>): Mesh;
  61876. /**
  61877. * Creates a tiled ground mesh
  61878. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61879. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61880. * * 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
  61881. * * 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
  61882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61883. * @param name defines the name of the mesh
  61884. * @param options defines the options used to create the mesh
  61885. * @param scene defines the hosting scene
  61886. * @returns the tiled ground mesh
  61887. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61888. */
  61889. static CreateTiledGround(name: string, options: {
  61890. xmin: number;
  61891. zmin: number;
  61892. xmax: number;
  61893. zmax: number;
  61894. subdivisions?: {
  61895. w: number;
  61896. h: number;
  61897. };
  61898. precision?: {
  61899. w: number;
  61900. h: number;
  61901. };
  61902. updatable?: boolean;
  61903. }, scene?: Nullable<Scene>): Mesh;
  61904. /**
  61905. * Creates a ground mesh from a height map
  61906. * * The parameter `url` sets the URL of the height map image resource.
  61907. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61908. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61909. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61910. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61911. * * 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.
  61912. * * 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).
  61913. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61915. * @param name defines the name of the mesh
  61916. * @param url defines the url to the height map
  61917. * @param options defines the options used to create the mesh
  61918. * @param scene defines the hosting scene
  61919. * @returns the ground mesh
  61920. * @see https://doc.babylonjs.com/babylon101/height_map
  61921. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61922. */
  61923. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61924. width?: number;
  61925. height?: number;
  61926. subdivisions?: number;
  61927. minHeight?: number;
  61928. maxHeight?: number;
  61929. colorFilter?: Color3;
  61930. alphaFilter?: number;
  61931. updatable?: boolean;
  61932. onReady?: (mesh: GroundMesh) => void;
  61933. }, scene?: Nullable<Scene>): GroundMesh;
  61934. /**
  61935. * Creates a polygon mesh
  61936. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61937. * * 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
  61938. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61940. * * 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)
  61941. * * Remember you can only change the shape positions, not their number when updating a polygon
  61942. * @param name defines the name of the mesh
  61943. * @param options defines the options used to create the mesh
  61944. * @param scene defines the hosting scene
  61945. * @param earcutInjection can be used to inject your own earcut reference
  61946. * @returns the polygon mesh
  61947. */
  61948. static CreatePolygon(name: string, options: {
  61949. shape: Vector3[];
  61950. holes?: Vector3[][];
  61951. depth?: number;
  61952. faceUV?: Vector4[];
  61953. faceColors?: Color4[];
  61954. updatable?: boolean;
  61955. sideOrientation?: number;
  61956. frontUVs?: Vector4;
  61957. backUVs?: Vector4;
  61958. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61959. /**
  61960. * Creates an extruded polygon mesh, with depth in the Y direction.
  61961. * * 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)
  61962. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61963. * @param name defines the name of the mesh
  61964. * @param options defines the options used to create the mesh
  61965. * @param scene defines the hosting scene
  61966. * @param earcutInjection can be used to inject your own earcut reference
  61967. * @returns the polygon mesh
  61968. */
  61969. static ExtrudePolygon(name: string, options: {
  61970. shape: Vector3[];
  61971. holes?: Vector3[][];
  61972. depth?: number;
  61973. faceUV?: Vector4[];
  61974. faceColors?: Color4[];
  61975. updatable?: boolean;
  61976. sideOrientation?: number;
  61977. frontUVs?: Vector4;
  61978. backUVs?: Vector4;
  61979. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61980. /**
  61981. * Creates a tube mesh.
  61982. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61983. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61984. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61985. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61986. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61987. * * 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)
  61988. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61989. * * 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
  61990. * * 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
  61991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61992. * * 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
  61993. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61995. * @param name defines the name of the mesh
  61996. * @param options defines the options used to create the mesh
  61997. * @param scene defines the hosting scene
  61998. * @returns the tube mesh
  61999. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62000. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62001. */
  62002. static CreateTube(name: string, options: {
  62003. path: Vector3[];
  62004. radius?: number;
  62005. tessellation?: number;
  62006. radiusFunction?: {
  62007. (i: number, distance: number): number;
  62008. };
  62009. cap?: number;
  62010. arc?: number;
  62011. updatable?: boolean;
  62012. sideOrientation?: number;
  62013. frontUVs?: Vector4;
  62014. backUVs?: Vector4;
  62015. instance?: Mesh;
  62016. invertUV?: boolean;
  62017. }, scene?: Nullable<Scene>): Mesh;
  62018. /**
  62019. * Creates a polyhedron mesh
  62020. * * 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
  62021. * * The parameter `size` (positive float, default 1) sets the polygon size
  62022. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62023. * * 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`
  62024. * * 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
  62025. * * 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)`)
  62026. * * 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
  62027. * * 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
  62028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62029. * * 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
  62030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62031. * @param name defines the name of the mesh
  62032. * @param options defines the options used to create the mesh
  62033. * @param scene defines the hosting scene
  62034. * @returns the polyhedron mesh
  62035. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62036. */
  62037. static CreatePolyhedron(name: string, options: {
  62038. type?: number;
  62039. size?: number;
  62040. sizeX?: number;
  62041. sizeY?: number;
  62042. sizeZ?: number;
  62043. custom?: any;
  62044. faceUV?: Vector4[];
  62045. faceColors?: Color4[];
  62046. flat?: boolean;
  62047. updatable?: boolean;
  62048. sideOrientation?: number;
  62049. frontUVs?: Vector4;
  62050. backUVs?: Vector4;
  62051. }, scene?: Nullable<Scene>): Mesh;
  62052. /**
  62053. * Creates a decal mesh.
  62054. * 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
  62055. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62056. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62057. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62058. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62059. * @param name defines the name of the mesh
  62060. * @param sourceMesh defines the mesh where the decal must be applied
  62061. * @param options defines the options used to create the mesh
  62062. * @param scene defines the hosting scene
  62063. * @returns the decal mesh
  62064. * @see https://doc.babylonjs.com/how_to/decals
  62065. */
  62066. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62067. position?: Vector3;
  62068. normal?: Vector3;
  62069. size?: Vector3;
  62070. angle?: number;
  62071. }): Mesh;
  62072. }
  62073. }
  62074. declare module BABYLON {
  62075. /**
  62076. * A simplifier interface for future simplification implementations
  62077. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62078. */
  62079. export interface ISimplifier {
  62080. /**
  62081. * Simplification of a given mesh according to the given settings.
  62082. * Since this requires computation, it is assumed that the function runs async.
  62083. * @param settings The settings of the simplification, including quality and distance
  62084. * @param successCallback A callback that will be called after the mesh was simplified.
  62085. * @param errorCallback in case of an error, this callback will be called. optional.
  62086. */
  62087. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62088. }
  62089. /**
  62090. * Expected simplification settings.
  62091. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62093. */
  62094. export interface ISimplificationSettings {
  62095. /**
  62096. * Gets or sets the expected quality
  62097. */
  62098. quality: number;
  62099. /**
  62100. * Gets or sets the distance when this optimized version should be used
  62101. */
  62102. distance: number;
  62103. /**
  62104. * Gets an already optimized mesh
  62105. */
  62106. optimizeMesh?: boolean;
  62107. }
  62108. /**
  62109. * Class used to specify simplification options
  62110. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62111. */
  62112. export class SimplificationSettings implements ISimplificationSettings {
  62113. /** expected quality */
  62114. quality: number;
  62115. /** distance when this optimized version should be used */
  62116. distance: number;
  62117. /** already optimized mesh */
  62118. optimizeMesh?: boolean | undefined;
  62119. /**
  62120. * Creates a SimplificationSettings
  62121. * @param quality expected quality
  62122. * @param distance distance when this optimized version should be used
  62123. * @param optimizeMesh already optimized mesh
  62124. */
  62125. constructor(
  62126. /** expected quality */
  62127. quality: number,
  62128. /** distance when this optimized version should be used */
  62129. distance: number,
  62130. /** already optimized mesh */
  62131. optimizeMesh?: boolean | undefined);
  62132. }
  62133. /**
  62134. * Interface used to define a simplification task
  62135. */
  62136. export interface ISimplificationTask {
  62137. /**
  62138. * Array of settings
  62139. */
  62140. settings: Array<ISimplificationSettings>;
  62141. /**
  62142. * Simplification type
  62143. */
  62144. simplificationType: SimplificationType;
  62145. /**
  62146. * Mesh to simplify
  62147. */
  62148. mesh: Mesh;
  62149. /**
  62150. * Callback called on success
  62151. */
  62152. successCallback?: () => void;
  62153. /**
  62154. * Defines if parallel processing can be used
  62155. */
  62156. parallelProcessing: boolean;
  62157. }
  62158. /**
  62159. * Queue used to order the simplification tasks
  62160. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62161. */
  62162. export class SimplificationQueue {
  62163. private _simplificationArray;
  62164. /**
  62165. * Gets a boolean indicating that the process is still running
  62166. */
  62167. running: boolean;
  62168. /**
  62169. * Creates a new queue
  62170. */
  62171. constructor();
  62172. /**
  62173. * Adds a new simplification task
  62174. * @param task defines a task to add
  62175. */
  62176. addTask(task: ISimplificationTask): void;
  62177. /**
  62178. * Execute next task
  62179. */
  62180. executeNext(): void;
  62181. /**
  62182. * Execute a simplification task
  62183. * @param task defines the task to run
  62184. */
  62185. runSimplification(task: ISimplificationTask): void;
  62186. private getSimplifier;
  62187. }
  62188. /**
  62189. * The implemented types of simplification
  62190. * At the moment only Quadratic Error Decimation is implemented
  62191. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62192. */
  62193. export enum SimplificationType {
  62194. /** Quadratic error decimation */
  62195. QUADRATIC = 0
  62196. }
  62197. /**
  62198. * An implementation of the Quadratic Error simplification algorithm.
  62199. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62200. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62201. * @author RaananW
  62202. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62203. */
  62204. export class QuadraticErrorSimplification implements ISimplifier {
  62205. private _mesh;
  62206. private triangles;
  62207. private vertices;
  62208. private references;
  62209. private _reconstructedMesh;
  62210. /** Gets or sets the number pf sync interations */
  62211. syncIterations: number;
  62212. /** Gets or sets the aggressiveness of the simplifier */
  62213. aggressiveness: number;
  62214. /** Gets or sets the number of allowed iterations for decimation */
  62215. decimationIterations: number;
  62216. /** Gets or sets the espilon to use for bounding box computation */
  62217. boundingBoxEpsilon: number;
  62218. /**
  62219. * Creates a new QuadraticErrorSimplification
  62220. * @param _mesh defines the target mesh
  62221. */
  62222. constructor(_mesh: Mesh);
  62223. /**
  62224. * Simplification of a given mesh according to the given settings.
  62225. * Since this requires computation, it is assumed that the function runs async.
  62226. * @param settings The settings of the simplification, including quality and distance
  62227. * @param successCallback A callback that will be called after the mesh was simplified.
  62228. */
  62229. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62230. private runDecimation;
  62231. private initWithMesh;
  62232. private init;
  62233. private reconstructMesh;
  62234. private initDecimatedMesh;
  62235. private isFlipped;
  62236. private updateTriangles;
  62237. private identifyBorder;
  62238. private updateMesh;
  62239. private vertexError;
  62240. private calculateError;
  62241. }
  62242. }
  62243. declare module BABYLON {
  62244. interface Scene {
  62245. /** @hidden (Backing field) */
  62246. _simplificationQueue: SimplificationQueue;
  62247. /**
  62248. * Gets or sets the simplification queue attached to the scene
  62249. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62250. */
  62251. simplificationQueue: SimplificationQueue;
  62252. }
  62253. interface Mesh {
  62254. /**
  62255. * Simplify the mesh according to the given array of settings.
  62256. * Function will return immediately and will simplify async
  62257. * @param settings a collection of simplification settings
  62258. * @param parallelProcessing should all levels calculate parallel or one after the other
  62259. * @param simplificationType the type of simplification to run
  62260. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62261. * @returns the current mesh
  62262. */
  62263. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62264. }
  62265. /**
  62266. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62267. * created in a scene
  62268. */
  62269. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62270. /**
  62271. * The component name helpfull to identify the component in the list of scene components.
  62272. */
  62273. readonly name: string;
  62274. /**
  62275. * The scene the component belongs to.
  62276. */
  62277. scene: Scene;
  62278. /**
  62279. * Creates a new instance of the component for the given scene
  62280. * @param scene Defines the scene to register the component in
  62281. */
  62282. constructor(scene: Scene);
  62283. /**
  62284. * Registers the component in a given scene
  62285. */
  62286. register(): void;
  62287. /**
  62288. * Rebuilds the elements related to this component in case of
  62289. * context lost for instance.
  62290. */
  62291. rebuild(): void;
  62292. /**
  62293. * Disposes the component and the associated ressources
  62294. */
  62295. dispose(): void;
  62296. private _beforeCameraUpdate;
  62297. }
  62298. }
  62299. declare module BABYLON {
  62300. /**
  62301. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62302. */
  62303. export interface INavigationEnginePlugin {
  62304. /**
  62305. * plugin name
  62306. */
  62307. name: string;
  62308. /**
  62309. * Creates a navigation mesh
  62310. * @param meshes array of all the geometry used to compute the navigatio mesh
  62311. * @param parameters bunch of parameters used to filter geometry
  62312. */
  62313. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62314. /**
  62315. * Create a navigation mesh debug mesh
  62316. * @param scene is where the mesh will be added
  62317. * @returns debug display mesh
  62318. */
  62319. createDebugNavMesh(scene: Scene): Mesh;
  62320. /**
  62321. * Get a navigation mesh constrained position, closest to the parameter position
  62322. * @param position world position
  62323. * @returns the closest point to position constrained by the navigation mesh
  62324. */
  62325. getClosestPoint(position: Vector3): Vector3;
  62326. /**
  62327. * Get a navigation mesh constrained position, closest to the parameter position
  62328. * @param position world position
  62329. * @param result output the closest point to position constrained by the navigation mesh
  62330. */
  62331. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62332. /**
  62333. * Get a navigation mesh constrained position, within a particular radius
  62334. * @param position world position
  62335. * @param maxRadius the maximum distance to the constrained world position
  62336. * @returns the closest point to position constrained by the navigation mesh
  62337. */
  62338. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62339. /**
  62340. * Get a navigation mesh constrained position, within a particular radius
  62341. * @param position world position
  62342. * @param maxRadius the maximum distance to the constrained world position
  62343. * @param result output the closest point to position constrained by the navigation mesh
  62344. */
  62345. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62346. /**
  62347. * Compute the final position from a segment made of destination-position
  62348. * @param position world position
  62349. * @param destination world position
  62350. * @returns the resulting point along the navmesh
  62351. */
  62352. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62353. /**
  62354. * Compute the final position from a segment made of destination-position
  62355. * @param position world position
  62356. * @param destination world position
  62357. * @param result output the resulting point along the navmesh
  62358. */
  62359. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62360. /**
  62361. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62362. * @param start world position
  62363. * @param end world position
  62364. * @returns array containing world position composing the path
  62365. */
  62366. computePath(start: Vector3, end: Vector3): Vector3[];
  62367. /**
  62368. * If this plugin is supported
  62369. * @returns true if plugin is supported
  62370. */
  62371. isSupported(): boolean;
  62372. /**
  62373. * Create a new Crowd so you can add agents
  62374. * @param maxAgents the maximum agent count in the crowd
  62375. * @param maxAgentRadius the maximum radius an agent can have
  62376. * @param scene to attach the crowd to
  62377. * @returns the crowd you can add agents to
  62378. */
  62379. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62380. /**
  62381. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62382. * The queries will try to find a solution within those bounds
  62383. * default is (1,1,1)
  62384. * @param extent x,y,z value that define the extent around the queries point of reference
  62385. */
  62386. setDefaultQueryExtent(extent: Vector3): void;
  62387. /**
  62388. * Get the Bounding box extent specified by setDefaultQueryExtent
  62389. * @returns the box extent values
  62390. */
  62391. getDefaultQueryExtent(): Vector3;
  62392. /**
  62393. * build the navmesh from a previously saved state using getNavmeshData
  62394. * @param data the Uint8Array returned by getNavmeshData
  62395. */
  62396. buildFromNavmeshData(data: Uint8Array): void;
  62397. /**
  62398. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62399. * @returns data the Uint8Array that can be saved and reused
  62400. */
  62401. getNavmeshData(): Uint8Array;
  62402. /**
  62403. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62404. * @param result output the box extent values
  62405. */
  62406. getDefaultQueryExtentToRef(result: Vector3): void;
  62407. /**
  62408. * Release all resources
  62409. */
  62410. dispose(): void;
  62411. }
  62412. /**
  62413. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62414. */
  62415. export interface ICrowd {
  62416. /**
  62417. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62418. * You can attach anything to that node. The node position is updated in the scene update tick.
  62419. * @param pos world position that will be constrained by the navigation mesh
  62420. * @param parameters agent parameters
  62421. * @param transform hooked to the agent that will be update by the scene
  62422. * @returns agent index
  62423. */
  62424. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62425. /**
  62426. * Returns the agent position in world space
  62427. * @param index agent index returned by addAgent
  62428. * @returns world space position
  62429. */
  62430. getAgentPosition(index: number): Vector3;
  62431. /**
  62432. * Gets the agent position result in world space
  62433. * @param index agent index returned by addAgent
  62434. * @param result output world space position
  62435. */
  62436. getAgentPositionToRef(index: number, result: Vector3): void;
  62437. /**
  62438. * Gets the agent velocity in world space
  62439. * @param index agent index returned by addAgent
  62440. * @returns world space velocity
  62441. */
  62442. getAgentVelocity(index: number): Vector3;
  62443. /**
  62444. * Gets the agent velocity result in world space
  62445. * @param index agent index returned by addAgent
  62446. * @param result output world space velocity
  62447. */
  62448. getAgentVelocityToRef(index: number, result: Vector3): void;
  62449. /**
  62450. * remove a particular agent previously created
  62451. * @param index agent index returned by addAgent
  62452. */
  62453. removeAgent(index: number): void;
  62454. /**
  62455. * get the list of all agents attached to this crowd
  62456. * @returns list of agent indices
  62457. */
  62458. getAgents(): number[];
  62459. /**
  62460. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62461. * @param deltaTime in seconds
  62462. */
  62463. update(deltaTime: number): void;
  62464. /**
  62465. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62466. * @param index agent index returned by addAgent
  62467. * @param destination targeted world position
  62468. */
  62469. agentGoto(index: number, destination: Vector3): void;
  62470. /**
  62471. * Teleport the agent to a new position
  62472. * @param index agent index returned by addAgent
  62473. * @param destination targeted world position
  62474. */
  62475. agentTeleport(index: number, destination: Vector3): void;
  62476. /**
  62477. * Update agent parameters
  62478. * @param index agent index returned by addAgent
  62479. * @param parameters agent parameters
  62480. */
  62481. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62482. /**
  62483. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62484. * The queries will try to find a solution within those bounds
  62485. * default is (1,1,1)
  62486. * @param extent x,y,z value that define the extent around the queries point of reference
  62487. */
  62488. setDefaultQueryExtent(extent: Vector3): void;
  62489. /**
  62490. * Get the Bounding box extent specified by setDefaultQueryExtent
  62491. * @returns the box extent values
  62492. */
  62493. getDefaultQueryExtent(): Vector3;
  62494. /**
  62495. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62496. * @param result output the box extent values
  62497. */
  62498. getDefaultQueryExtentToRef(result: Vector3): void;
  62499. /**
  62500. * Release all resources
  62501. */
  62502. dispose(): void;
  62503. }
  62504. /**
  62505. * Configures an agent
  62506. */
  62507. export interface IAgentParameters {
  62508. /**
  62509. * Agent radius. [Limit: >= 0]
  62510. */
  62511. radius: number;
  62512. /**
  62513. * Agent height. [Limit: > 0]
  62514. */
  62515. height: number;
  62516. /**
  62517. * Maximum allowed acceleration. [Limit: >= 0]
  62518. */
  62519. maxAcceleration: number;
  62520. /**
  62521. * Maximum allowed speed. [Limit: >= 0]
  62522. */
  62523. maxSpeed: number;
  62524. /**
  62525. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62526. */
  62527. collisionQueryRange: number;
  62528. /**
  62529. * The path visibility optimization range. [Limit: > 0]
  62530. */
  62531. pathOptimizationRange: number;
  62532. /**
  62533. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62534. */
  62535. separationWeight: number;
  62536. }
  62537. /**
  62538. * Configures the navigation mesh creation
  62539. */
  62540. export interface INavMeshParameters {
  62541. /**
  62542. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62543. */
  62544. cs: number;
  62545. /**
  62546. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62547. */
  62548. ch: number;
  62549. /**
  62550. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62551. */
  62552. walkableSlopeAngle: number;
  62553. /**
  62554. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62555. * be considered walkable. [Limit: >= 3] [Units: vx]
  62556. */
  62557. walkableHeight: number;
  62558. /**
  62559. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62560. */
  62561. walkableClimb: number;
  62562. /**
  62563. * The distance to erode/shrink the walkable area of the heightfield away from
  62564. * obstructions. [Limit: >=0] [Units: vx]
  62565. */
  62566. walkableRadius: number;
  62567. /**
  62568. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62569. */
  62570. maxEdgeLen: number;
  62571. /**
  62572. * The maximum distance a simplfied contour's border edges should deviate
  62573. * the original raw contour. [Limit: >=0] [Units: vx]
  62574. */
  62575. maxSimplificationError: number;
  62576. /**
  62577. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62578. */
  62579. minRegionArea: number;
  62580. /**
  62581. * Any regions with a span count smaller than this value will, if possible,
  62582. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62583. */
  62584. mergeRegionArea: number;
  62585. /**
  62586. * The maximum number of vertices allowed for polygons generated during the
  62587. * contour to polygon conversion process. [Limit: >= 3]
  62588. */
  62589. maxVertsPerPoly: number;
  62590. /**
  62591. * Sets the sampling distance to use when generating the detail mesh.
  62592. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62593. */
  62594. detailSampleDist: number;
  62595. /**
  62596. * The maximum distance the detail mesh surface should deviate from heightfield
  62597. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62598. */
  62599. detailSampleMaxError: number;
  62600. }
  62601. }
  62602. declare module BABYLON {
  62603. /**
  62604. * RecastJS navigation plugin
  62605. */
  62606. export class RecastJSPlugin implements INavigationEnginePlugin {
  62607. /**
  62608. * Reference to the Recast library
  62609. */
  62610. bjsRECAST: any;
  62611. /**
  62612. * plugin name
  62613. */
  62614. name: string;
  62615. /**
  62616. * the first navmesh created. We might extend this to support multiple navmeshes
  62617. */
  62618. navMesh: any;
  62619. /**
  62620. * Initializes the recastJS plugin
  62621. * @param recastInjection can be used to inject your own recast reference
  62622. */
  62623. constructor(recastInjection?: any);
  62624. /**
  62625. * Creates a navigation mesh
  62626. * @param meshes array of all the geometry used to compute the navigatio mesh
  62627. * @param parameters bunch of parameters used to filter geometry
  62628. */
  62629. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62630. /**
  62631. * Create a navigation mesh debug mesh
  62632. * @param scene is where the mesh will be added
  62633. * @returns debug display mesh
  62634. */
  62635. createDebugNavMesh(scene: Scene): Mesh;
  62636. /**
  62637. * Get a navigation mesh constrained position, closest to the parameter position
  62638. * @param position world position
  62639. * @returns the closest point to position constrained by the navigation mesh
  62640. */
  62641. getClosestPoint(position: Vector3): Vector3;
  62642. /**
  62643. * Get a navigation mesh constrained position, closest to the parameter position
  62644. * @param position world position
  62645. * @param result output the closest point to position constrained by the navigation mesh
  62646. */
  62647. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62648. /**
  62649. * Get a navigation mesh constrained position, within a particular radius
  62650. * @param position world position
  62651. * @param maxRadius the maximum distance to the constrained world position
  62652. * @returns the closest point to position constrained by the navigation mesh
  62653. */
  62654. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62655. /**
  62656. * Get a navigation mesh constrained position, within a particular radius
  62657. * @param position world position
  62658. * @param maxRadius the maximum distance to the constrained world position
  62659. * @param result output the closest point to position constrained by the navigation mesh
  62660. */
  62661. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62662. /**
  62663. * Compute the final position from a segment made of destination-position
  62664. * @param position world position
  62665. * @param destination world position
  62666. * @returns the resulting point along the navmesh
  62667. */
  62668. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62669. /**
  62670. * Compute the final position from a segment made of destination-position
  62671. * @param position world position
  62672. * @param destination world position
  62673. * @param result output the resulting point along the navmesh
  62674. */
  62675. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62676. /**
  62677. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62678. * @param start world position
  62679. * @param end world position
  62680. * @returns array containing world position composing the path
  62681. */
  62682. computePath(start: Vector3, end: Vector3): Vector3[];
  62683. /**
  62684. * Create a new Crowd so you can add agents
  62685. * @param maxAgents the maximum agent count in the crowd
  62686. * @param maxAgentRadius the maximum radius an agent can have
  62687. * @param scene to attach the crowd to
  62688. * @returns the crowd you can add agents to
  62689. */
  62690. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62691. /**
  62692. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62693. * The queries will try to find a solution within those bounds
  62694. * default is (1,1,1)
  62695. * @param extent x,y,z value that define the extent around the queries point of reference
  62696. */
  62697. setDefaultQueryExtent(extent: Vector3): void;
  62698. /**
  62699. * Get the Bounding box extent specified by setDefaultQueryExtent
  62700. * @returns the box extent values
  62701. */
  62702. getDefaultQueryExtent(): Vector3;
  62703. /**
  62704. * build the navmesh from a previously saved state using getNavmeshData
  62705. * @param data the Uint8Array returned by getNavmeshData
  62706. */
  62707. buildFromNavmeshData(data: Uint8Array): void;
  62708. /**
  62709. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62710. * @returns data the Uint8Array that can be saved and reused
  62711. */
  62712. getNavmeshData(): Uint8Array;
  62713. /**
  62714. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62715. * @param result output the box extent values
  62716. */
  62717. getDefaultQueryExtentToRef(result: Vector3): void;
  62718. /**
  62719. * Disposes
  62720. */
  62721. dispose(): void;
  62722. /**
  62723. * If this plugin is supported
  62724. * @returns true if plugin is supported
  62725. */
  62726. isSupported(): boolean;
  62727. }
  62728. /**
  62729. * Recast detour crowd implementation
  62730. */
  62731. export class RecastJSCrowd implements ICrowd {
  62732. /**
  62733. * Recast/detour plugin
  62734. */
  62735. bjsRECASTPlugin: RecastJSPlugin;
  62736. /**
  62737. * Link to the detour crowd
  62738. */
  62739. recastCrowd: any;
  62740. /**
  62741. * One transform per agent
  62742. */
  62743. transforms: TransformNode[];
  62744. /**
  62745. * All agents created
  62746. */
  62747. agents: number[];
  62748. /**
  62749. * Link to the scene is kept to unregister the crowd from the scene
  62750. */
  62751. private _scene;
  62752. /**
  62753. * Observer for crowd updates
  62754. */
  62755. private _onBeforeAnimationsObserver;
  62756. /**
  62757. * Constructor
  62758. * @param plugin recastJS plugin
  62759. * @param maxAgents the maximum agent count in the crowd
  62760. * @param maxAgentRadius the maximum radius an agent can have
  62761. * @param scene to attach the crowd to
  62762. * @returns the crowd you can add agents to
  62763. */
  62764. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62765. /**
  62766. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62767. * You can attach anything to that node. The node position is updated in the scene update tick.
  62768. * @param pos world position that will be constrained by the navigation mesh
  62769. * @param parameters agent parameters
  62770. * @param transform hooked to the agent that will be update by the scene
  62771. * @returns agent index
  62772. */
  62773. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62774. /**
  62775. * Returns the agent position in world space
  62776. * @param index agent index returned by addAgent
  62777. * @returns world space position
  62778. */
  62779. getAgentPosition(index: number): Vector3;
  62780. /**
  62781. * Returns the agent position result in world space
  62782. * @param index agent index returned by addAgent
  62783. * @param result output world space position
  62784. */
  62785. getAgentPositionToRef(index: number, result: Vector3): void;
  62786. /**
  62787. * Returns the agent velocity in world space
  62788. * @param index agent index returned by addAgent
  62789. * @returns world space velocity
  62790. */
  62791. getAgentVelocity(index: number): Vector3;
  62792. /**
  62793. * Returns the agent velocity result in world space
  62794. * @param index agent index returned by addAgent
  62795. * @param result output world space velocity
  62796. */
  62797. getAgentVelocityToRef(index: number, result: Vector3): void;
  62798. /**
  62799. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62800. * @param index agent index returned by addAgent
  62801. * @param destination targeted world position
  62802. */
  62803. agentGoto(index: number, destination: Vector3): void;
  62804. /**
  62805. * Teleport the agent to a new position
  62806. * @param index agent index returned by addAgent
  62807. * @param destination targeted world position
  62808. */
  62809. agentTeleport(index: number, destination: Vector3): void;
  62810. /**
  62811. * Update agent parameters
  62812. * @param index agent index returned by addAgent
  62813. * @param parameters agent parameters
  62814. */
  62815. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62816. /**
  62817. * remove a particular agent previously created
  62818. * @param index agent index returned by addAgent
  62819. */
  62820. removeAgent(index: number): void;
  62821. /**
  62822. * get the list of all agents attached to this crowd
  62823. * @returns list of agent indices
  62824. */
  62825. getAgents(): number[];
  62826. /**
  62827. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62828. * @param deltaTime in seconds
  62829. */
  62830. update(deltaTime: number): void;
  62831. /**
  62832. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62833. * The queries will try to find a solution within those bounds
  62834. * default is (1,1,1)
  62835. * @param extent x,y,z value that define the extent around the queries point of reference
  62836. */
  62837. setDefaultQueryExtent(extent: Vector3): void;
  62838. /**
  62839. * Get the Bounding box extent specified by setDefaultQueryExtent
  62840. * @returns the box extent values
  62841. */
  62842. getDefaultQueryExtent(): Vector3;
  62843. /**
  62844. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62845. * @param result output the box extent values
  62846. */
  62847. getDefaultQueryExtentToRef(result: Vector3): void;
  62848. /**
  62849. * Release all resources
  62850. */
  62851. dispose(): void;
  62852. }
  62853. }
  62854. declare module BABYLON {
  62855. /**
  62856. * Class used to enable access to IndexedDB
  62857. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62858. */
  62859. export class Database implements IOfflineProvider {
  62860. private _callbackManifestChecked;
  62861. private _currentSceneUrl;
  62862. private _db;
  62863. private _enableSceneOffline;
  62864. private _enableTexturesOffline;
  62865. private _manifestVersionFound;
  62866. private _mustUpdateRessources;
  62867. private _hasReachedQuota;
  62868. private _isSupported;
  62869. private _idbFactory;
  62870. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62871. private static IsUASupportingBlobStorage;
  62872. /**
  62873. * Gets a boolean indicating if Database storate is enabled (off by default)
  62874. */
  62875. static IDBStorageEnabled: boolean;
  62876. /**
  62877. * Gets a boolean indicating if scene must be saved in the database
  62878. */
  62879. get enableSceneOffline(): boolean;
  62880. /**
  62881. * Gets a boolean indicating if textures must be saved in the database
  62882. */
  62883. get enableTexturesOffline(): boolean;
  62884. /**
  62885. * Creates a new Database
  62886. * @param urlToScene defines the url to load the scene
  62887. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62888. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62889. */
  62890. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62891. private static _ParseURL;
  62892. private static _ReturnFullUrlLocation;
  62893. private _checkManifestFile;
  62894. /**
  62895. * Open the database and make it available
  62896. * @param successCallback defines the callback to call on success
  62897. * @param errorCallback defines the callback to call on error
  62898. */
  62899. open(successCallback: () => void, errorCallback: () => void): void;
  62900. /**
  62901. * Loads an image from the database
  62902. * @param url defines the url to load from
  62903. * @param image defines the target DOM image
  62904. */
  62905. loadImage(url: string, image: HTMLImageElement): void;
  62906. private _loadImageFromDBAsync;
  62907. private _saveImageIntoDBAsync;
  62908. private _checkVersionFromDB;
  62909. private _loadVersionFromDBAsync;
  62910. private _saveVersionIntoDBAsync;
  62911. /**
  62912. * Loads a file from database
  62913. * @param url defines the URL to load from
  62914. * @param sceneLoaded defines a callback to call on success
  62915. * @param progressCallBack defines a callback to call when progress changed
  62916. * @param errorCallback defines a callback to call on error
  62917. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62918. */
  62919. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62920. private _loadFileAsync;
  62921. private _saveFileAsync;
  62922. /**
  62923. * Validates if xhr data is correct
  62924. * @param xhr defines the request to validate
  62925. * @param dataType defines the expected data type
  62926. * @returns true if data is correct
  62927. */
  62928. private static _ValidateXHRData;
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /** @hidden */
  62933. export var gpuUpdateParticlesPixelShader: {
  62934. name: string;
  62935. shader: string;
  62936. };
  62937. }
  62938. declare module BABYLON {
  62939. /** @hidden */
  62940. export var gpuUpdateParticlesVertexShader: {
  62941. name: string;
  62942. shader: string;
  62943. };
  62944. }
  62945. declare module BABYLON {
  62946. /** @hidden */
  62947. export var clipPlaneFragmentDeclaration2: {
  62948. name: string;
  62949. shader: string;
  62950. };
  62951. }
  62952. declare module BABYLON {
  62953. /** @hidden */
  62954. export var gpuRenderParticlesPixelShader: {
  62955. name: string;
  62956. shader: string;
  62957. };
  62958. }
  62959. declare module BABYLON {
  62960. /** @hidden */
  62961. export var clipPlaneVertexDeclaration2: {
  62962. name: string;
  62963. shader: string;
  62964. };
  62965. }
  62966. declare module BABYLON {
  62967. /** @hidden */
  62968. export var gpuRenderParticlesVertexShader: {
  62969. name: string;
  62970. shader: string;
  62971. };
  62972. }
  62973. declare module BABYLON {
  62974. /**
  62975. * This represents a GPU particle system in Babylon
  62976. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62977. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62978. */
  62979. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62980. /**
  62981. * The layer mask we are rendering the particles through.
  62982. */
  62983. layerMask: number;
  62984. private _capacity;
  62985. private _activeCount;
  62986. private _currentActiveCount;
  62987. private _accumulatedCount;
  62988. private _renderEffect;
  62989. private _updateEffect;
  62990. private _buffer0;
  62991. private _buffer1;
  62992. private _spriteBuffer;
  62993. private _updateVAO;
  62994. private _renderVAO;
  62995. private _targetIndex;
  62996. private _sourceBuffer;
  62997. private _targetBuffer;
  62998. private _engine;
  62999. private _currentRenderId;
  63000. private _started;
  63001. private _stopped;
  63002. private _timeDelta;
  63003. private _randomTexture;
  63004. private _randomTexture2;
  63005. private _attributesStrideSize;
  63006. private _updateEffectOptions;
  63007. private _randomTextureSize;
  63008. private _actualFrame;
  63009. private readonly _rawTextureWidth;
  63010. /**
  63011. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63012. */
  63013. static get IsSupported(): boolean;
  63014. /**
  63015. * An event triggered when the system is disposed.
  63016. */
  63017. onDisposeObservable: Observable<GPUParticleSystem>;
  63018. /**
  63019. * Gets the maximum number of particles active at the same time.
  63020. * @returns The max number of active particles.
  63021. */
  63022. getCapacity(): number;
  63023. /**
  63024. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63025. * to override the particles.
  63026. */
  63027. forceDepthWrite: boolean;
  63028. /**
  63029. * Gets or set the number of active particles
  63030. */
  63031. get activeParticleCount(): number;
  63032. set activeParticleCount(value: number);
  63033. private _preWarmDone;
  63034. /**
  63035. * Specifies if the particles are updated in emitter local space or world space.
  63036. * This is always false for GPU particles
  63037. */
  63038. get isLocal(): boolean;
  63039. set isLocal(value: boolean);
  63040. /**
  63041. * Is this system ready to be used/rendered
  63042. * @return true if the system is ready
  63043. */
  63044. isReady(): boolean;
  63045. /**
  63046. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63047. * @returns True if it has been started, otherwise false.
  63048. */
  63049. isStarted(): boolean;
  63050. /**
  63051. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63052. * @returns True if it has been stopped, otherwise false.
  63053. */
  63054. isStopped(): boolean;
  63055. /**
  63056. * Gets a boolean indicating that the system is stopping
  63057. * @returns true if the system is currently stopping
  63058. */
  63059. isStopping(): boolean;
  63060. /**
  63061. * Gets the number of particles active at the same time.
  63062. * @returns The number of active particles.
  63063. */
  63064. getActiveCount(): number;
  63065. /**
  63066. * Starts the particle system and begins to emit
  63067. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63068. */
  63069. start(delay?: number): void;
  63070. /**
  63071. * Stops the particle system.
  63072. */
  63073. stop(): void;
  63074. /**
  63075. * Remove all active particles
  63076. */
  63077. reset(): void;
  63078. /**
  63079. * Returns the string "GPUParticleSystem"
  63080. * @returns a string containing the class name
  63081. */
  63082. getClassName(): string;
  63083. private _colorGradientsTexture;
  63084. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63085. /**
  63086. * Adds a new color gradient
  63087. * @param gradient defines the gradient to use (between 0 and 1)
  63088. * @param color1 defines the color to affect to the specified gradient
  63089. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63090. * @returns the current particle system
  63091. */
  63092. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63093. /**
  63094. * Remove a specific color gradient
  63095. * @param gradient defines the gradient to remove
  63096. * @returns the current particle system
  63097. */
  63098. removeColorGradient(gradient: number): GPUParticleSystem;
  63099. private _angularSpeedGradientsTexture;
  63100. private _sizeGradientsTexture;
  63101. private _velocityGradientsTexture;
  63102. private _limitVelocityGradientsTexture;
  63103. private _dragGradientsTexture;
  63104. private _addFactorGradient;
  63105. /**
  63106. * Adds a new size gradient
  63107. * @param gradient defines the gradient to use (between 0 and 1)
  63108. * @param factor defines the size factor to affect to the specified gradient
  63109. * @returns the current particle system
  63110. */
  63111. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63112. /**
  63113. * Remove a specific size gradient
  63114. * @param gradient defines the gradient to remove
  63115. * @returns the current particle system
  63116. */
  63117. removeSizeGradient(gradient: number): GPUParticleSystem;
  63118. /**
  63119. * Adds a new angular speed gradient
  63120. * @param gradient defines the gradient to use (between 0 and 1)
  63121. * @param factor defines the angular speed to affect to the specified gradient
  63122. * @returns the current particle system
  63123. */
  63124. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63125. /**
  63126. * Remove a specific angular speed gradient
  63127. * @param gradient defines the gradient to remove
  63128. * @returns the current particle system
  63129. */
  63130. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63131. /**
  63132. * Adds a new velocity gradient
  63133. * @param gradient defines the gradient to use (between 0 and 1)
  63134. * @param factor defines the velocity to affect to the specified gradient
  63135. * @returns the current particle system
  63136. */
  63137. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63138. /**
  63139. * Remove a specific velocity gradient
  63140. * @param gradient defines the gradient to remove
  63141. * @returns the current particle system
  63142. */
  63143. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63144. /**
  63145. * Adds a new limit velocity gradient
  63146. * @param gradient defines the gradient to use (between 0 and 1)
  63147. * @param factor defines the limit velocity value to affect to the specified gradient
  63148. * @returns the current particle system
  63149. */
  63150. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63151. /**
  63152. * Remove a specific limit velocity gradient
  63153. * @param gradient defines the gradient to remove
  63154. * @returns the current particle system
  63155. */
  63156. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63157. /**
  63158. * Adds a new drag gradient
  63159. * @param gradient defines the gradient to use (between 0 and 1)
  63160. * @param factor defines the drag value to affect to the specified gradient
  63161. * @returns the current particle system
  63162. */
  63163. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63164. /**
  63165. * Remove a specific drag gradient
  63166. * @param gradient defines the gradient to remove
  63167. * @returns the current particle system
  63168. */
  63169. removeDragGradient(gradient: number): GPUParticleSystem;
  63170. /**
  63171. * Not supported by GPUParticleSystem
  63172. * @param gradient defines the gradient to use (between 0 and 1)
  63173. * @param factor defines the emit rate value to affect to the specified gradient
  63174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63175. * @returns the current particle system
  63176. */
  63177. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63178. /**
  63179. * Not supported by GPUParticleSystem
  63180. * @param gradient defines the gradient to remove
  63181. * @returns the current particle system
  63182. */
  63183. removeEmitRateGradient(gradient: number): IParticleSystem;
  63184. /**
  63185. * Not supported by GPUParticleSystem
  63186. * @param gradient defines the gradient to use (between 0 and 1)
  63187. * @param factor defines the start size value to affect to the specified gradient
  63188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63189. * @returns the current particle system
  63190. */
  63191. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63192. /**
  63193. * Not supported by GPUParticleSystem
  63194. * @param gradient defines the gradient to remove
  63195. * @returns the current particle system
  63196. */
  63197. removeStartSizeGradient(gradient: number): IParticleSystem;
  63198. /**
  63199. * Not supported by GPUParticleSystem
  63200. * @param gradient defines the gradient to use (between 0 and 1)
  63201. * @param min defines the color remap minimal range
  63202. * @param max defines the color remap maximal range
  63203. * @returns the current particle system
  63204. */
  63205. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63206. /**
  63207. * Not supported by GPUParticleSystem
  63208. * @param gradient defines the gradient to remove
  63209. * @returns the current particle system
  63210. */
  63211. removeColorRemapGradient(): IParticleSystem;
  63212. /**
  63213. * Not supported by GPUParticleSystem
  63214. * @param gradient defines the gradient to use (between 0 and 1)
  63215. * @param min defines the alpha remap minimal range
  63216. * @param max defines the alpha remap maximal range
  63217. * @returns the current particle system
  63218. */
  63219. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63220. /**
  63221. * Not supported by GPUParticleSystem
  63222. * @param gradient defines the gradient to remove
  63223. * @returns the current particle system
  63224. */
  63225. removeAlphaRemapGradient(): IParticleSystem;
  63226. /**
  63227. * Not supported by GPUParticleSystem
  63228. * @param gradient defines the gradient to use (between 0 and 1)
  63229. * @param color defines the color to affect to the specified gradient
  63230. * @returns the current particle system
  63231. */
  63232. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63233. /**
  63234. * Not supported by GPUParticleSystem
  63235. * @param gradient defines the gradient to remove
  63236. * @returns the current particle system
  63237. */
  63238. removeRampGradient(): IParticleSystem;
  63239. /**
  63240. * Not supported by GPUParticleSystem
  63241. * @returns the list of ramp gradients
  63242. */
  63243. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63244. /**
  63245. * Not supported by GPUParticleSystem
  63246. * Gets or sets a boolean indicating that ramp gradients must be used
  63247. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63248. */
  63249. get useRampGradients(): boolean;
  63250. set useRampGradients(value: boolean);
  63251. /**
  63252. * Not supported by GPUParticleSystem
  63253. * @param gradient defines the gradient to use (between 0 and 1)
  63254. * @param factor defines the life time factor to affect to the specified gradient
  63255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63256. * @returns the current particle system
  63257. */
  63258. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63259. /**
  63260. * Not supported by GPUParticleSystem
  63261. * @param gradient defines the gradient to remove
  63262. * @returns the current particle system
  63263. */
  63264. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63265. /**
  63266. * Instantiates a GPU particle system.
  63267. * 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.
  63268. * @param name The name of the particle system
  63269. * @param options The options used to create the system
  63270. * @param scene The scene the particle system belongs to
  63271. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63272. */
  63273. constructor(name: string, options: Partial<{
  63274. capacity: number;
  63275. randomTextureSize: number;
  63276. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63277. protected _reset(): void;
  63278. private _createUpdateVAO;
  63279. private _createRenderVAO;
  63280. private _initialize;
  63281. /** @hidden */
  63282. _recreateUpdateEffect(): void;
  63283. /** @hidden */
  63284. _recreateRenderEffect(): void;
  63285. /**
  63286. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63287. * @param preWarm defines if we are in the pre-warmimg phase
  63288. */
  63289. animate(preWarm?: boolean): void;
  63290. private _createFactorGradientTexture;
  63291. private _createSizeGradientTexture;
  63292. private _createAngularSpeedGradientTexture;
  63293. private _createVelocityGradientTexture;
  63294. private _createLimitVelocityGradientTexture;
  63295. private _createDragGradientTexture;
  63296. private _createColorGradientTexture;
  63297. /**
  63298. * Renders the particle system in its current state
  63299. * @param preWarm defines if the system should only update the particles but not render them
  63300. * @returns the current number of particles
  63301. */
  63302. render(preWarm?: boolean): number;
  63303. /**
  63304. * Rebuilds the particle system
  63305. */
  63306. rebuild(): void;
  63307. private _releaseBuffers;
  63308. private _releaseVAOs;
  63309. /**
  63310. * Disposes the particle system and free the associated resources
  63311. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63312. */
  63313. dispose(disposeTexture?: boolean): void;
  63314. /**
  63315. * Clones the particle system.
  63316. * @param name The name of the cloned object
  63317. * @param newEmitter The new emitter to use
  63318. * @returns the cloned particle system
  63319. */
  63320. clone(name: string, newEmitter: any): GPUParticleSystem;
  63321. /**
  63322. * Serializes the particle system to a JSON object.
  63323. * @returns the JSON object
  63324. */
  63325. serialize(): any;
  63326. /**
  63327. * Parses a JSON object to create a GPU particle system.
  63328. * @param parsedParticleSystem The JSON object to parse
  63329. * @param scene The scene to create the particle system in
  63330. * @param rootUrl The root url to use to load external dependencies like texture
  63331. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63332. * @returns the parsed GPU particle system
  63333. */
  63334. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63335. }
  63336. }
  63337. declare module BABYLON {
  63338. /**
  63339. * Represents a set of particle systems working together to create a specific effect
  63340. */
  63341. export class ParticleSystemSet implements IDisposable {
  63342. /**
  63343. * Gets or sets base Assets URL
  63344. */
  63345. static BaseAssetsUrl: string;
  63346. private _emitterCreationOptions;
  63347. private _emitterNode;
  63348. /**
  63349. * Gets the particle system list
  63350. */
  63351. systems: IParticleSystem[];
  63352. /**
  63353. * Gets the emitter node used with this set
  63354. */
  63355. get emitterNode(): Nullable<TransformNode>;
  63356. /**
  63357. * Creates a new emitter mesh as a sphere
  63358. * @param options defines the options used to create the sphere
  63359. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63360. * @param scene defines the hosting scene
  63361. */
  63362. setEmitterAsSphere(options: {
  63363. diameter: number;
  63364. segments: number;
  63365. color: Color3;
  63366. }, renderingGroupId: number, scene: Scene): void;
  63367. /**
  63368. * Starts all particle systems of the set
  63369. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63370. */
  63371. start(emitter?: AbstractMesh): void;
  63372. /**
  63373. * Release all associated resources
  63374. */
  63375. dispose(): void;
  63376. /**
  63377. * Serialize the set into a JSON compatible object
  63378. * @returns a JSON compatible representation of the set
  63379. */
  63380. serialize(): any;
  63381. /**
  63382. * Parse a new ParticleSystemSet from a serialized source
  63383. * @param data defines a JSON compatible representation of the set
  63384. * @param scene defines the hosting scene
  63385. * @param gpu defines if we want GPU particles or CPU particles
  63386. * @returns a new ParticleSystemSet
  63387. */
  63388. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63389. }
  63390. }
  63391. declare module BABYLON {
  63392. /**
  63393. * This class is made for on one-liner static method to help creating particle system set.
  63394. */
  63395. export class ParticleHelper {
  63396. /**
  63397. * Gets or sets base Assets URL
  63398. */
  63399. static BaseAssetsUrl: string;
  63400. /**
  63401. * Create a default particle system that you can tweak
  63402. * @param emitter defines the emitter to use
  63403. * @param capacity defines the system capacity (default is 500 particles)
  63404. * @param scene defines the hosting scene
  63405. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63406. * @returns the new Particle system
  63407. */
  63408. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63409. /**
  63410. * This is the main static method (one-liner) of this helper to create different particle systems
  63411. * @param type This string represents the type to the particle system to create
  63412. * @param scene The scene where the particle system should live
  63413. * @param gpu If the system will use gpu
  63414. * @returns the ParticleSystemSet created
  63415. */
  63416. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63417. /**
  63418. * Static function used to export a particle system to a ParticleSystemSet variable.
  63419. * Please note that the emitter shape is not exported
  63420. * @param systems defines the particle systems to export
  63421. * @returns the created particle system set
  63422. */
  63423. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63424. }
  63425. }
  63426. declare module BABYLON {
  63427. interface Engine {
  63428. /**
  63429. * Create an effect to use with particle systems.
  63430. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63431. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63432. * @param uniformsNames defines a list of attribute names
  63433. * @param samplers defines an array of string used to represent textures
  63434. * @param defines defines the string containing the defines to use to compile the shaders
  63435. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63436. * @param onCompiled defines a function to call when the effect creation is successful
  63437. * @param onError defines a function to call when the effect creation has failed
  63438. * @returns the new Effect
  63439. */
  63440. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63441. }
  63442. interface Mesh {
  63443. /**
  63444. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63445. * @returns an array of IParticleSystem
  63446. */
  63447. getEmittedParticleSystems(): IParticleSystem[];
  63448. /**
  63449. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63450. * @returns an array of IParticleSystem
  63451. */
  63452. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63453. }
  63454. /**
  63455. * @hidden
  63456. */
  63457. export var _IDoNeedToBeInTheBuild: number;
  63458. }
  63459. declare module BABYLON {
  63460. /** Defines the 4 color options */
  63461. export enum PointColor {
  63462. /** color value */
  63463. Color = 2,
  63464. /** uv value */
  63465. UV = 1,
  63466. /** random value */
  63467. Random = 0,
  63468. /** stated value */
  63469. Stated = 3
  63470. }
  63471. /**
  63472. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63473. * 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.
  63474. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63475. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63476. *
  63477. * Full documentation here : TO BE ENTERED
  63478. */
  63479. export class PointsCloudSystem implements IDisposable {
  63480. /**
  63481. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63482. * Example : var p = SPS.particles[i];
  63483. */
  63484. particles: CloudPoint[];
  63485. /**
  63486. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63487. */
  63488. nbParticles: number;
  63489. /**
  63490. * This a counter for your own usage. It's not set by any SPS functions.
  63491. */
  63492. counter: number;
  63493. /**
  63494. * The PCS name. This name is also given to the underlying mesh.
  63495. */
  63496. name: string;
  63497. /**
  63498. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63499. */
  63500. mesh: Mesh;
  63501. /**
  63502. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63503. * Please read :
  63504. */
  63505. vars: any;
  63506. /**
  63507. * @hidden
  63508. */
  63509. _size: number;
  63510. private _scene;
  63511. private _promises;
  63512. private _positions;
  63513. private _indices;
  63514. private _normals;
  63515. private _colors;
  63516. private _uvs;
  63517. private _indices32;
  63518. private _positions32;
  63519. private _colors32;
  63520. private _uvs32;
  63521. private _updatable;
  63522. private _isVisibilityBoxLocked;
  63523. private _alwaysVisible;
  63524. private _groups;
  63525. private _groupCounter;
  63526. private _computeParticleColor;
  63527. private _computeParticleTexture;
  63528. private _computeParticleRotation;
  63529. private _computeBoundingBox;
  63530. private _isReady;
  63531. /**
  63532. * Creates a PCS (Points Cloud System) object
  63533. * @param name (String) is the PCS name, this will be the underlying mesh name
  63534. * @param pointSize (number) is the size for each point
  63535. * @param scene (Scene) is the scene in which the PCS is added
  63536. * @param options defines the options of the PCS e.g.
  63537. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63538. */
  63539. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63540. updatable?: boolean;
  63541. });
  63542. /**
  63543. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63544. * If no points were added to the PCS, the returned mesh is just a single point.
  63545. * @returns a promise for the created mesh
  63546. */
  63547. buildMeshAsync(): Promise<Mesh>;
  63548. /**
  63549. * @hidden
  63550. */
  63551. private _buildMesh;
  63552. private _addParticle;
  63553. private _randomUnitVector;
  63554. private _getColorIndicesForCoord;
  63555. private _setPointsColorOrUV;
  63556. private _colorFromTexture;
  63557. private _calculateDensity;
  63558. /**
  63559. * Adds points to the PCS in random positions within a unit sphere
  63560. * @param nb (positive integer) the number of particles to be created from this model
  63561. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63562. * @returns the number of groups in the system
  63563. */
  63564. addPoints(nb: number, pointFunction?: any): number;
  63565. /**
  63566. * Adds points to the PCS from the surface of the model shape
  63567. * @param mesh is any Mesh object that will be used as a surface model for the points
  63568. * @param nb (positive integer) the number of particles to be created from this model
  63569. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63570. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63571. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63572. * @returns the number of groups in the system
  63573. */
  63574. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63575. /**
  63576. * Adds points to the PCS inside the model shape
  63577. * @param mesh is any Mesh object that will be used as a surface model for the points
  63578. * @param nb (positive integer) the number of particles to be created from this model
  63579. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63580. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63581. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63582. * @returns the number of groups in the system
  63583. */
  63584. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63585. /**
  63586. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63587. * This method calls `updateParticle()` for each particle of the SPS.
  63588. * For an animated SPS, it is usually called within the render loop.
  63589. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63590. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63591. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63592. * @returns the PCS.
  63593. */
  63594. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63595. /**
  63596. * Disposes the PCS.
  63597. */
  63598. dispose(): void;
  63599. /**
  63600. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63601. * doc :
  63602. * @returns the PCS.
  63603. */
  63604. refreshVisibleSize(): PointsCloudSystem;
  63605. /**
  63606. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63607. * @param size the size (float) of the visibility box
  63608. * note : this doesn't lock the PCS mesh bounding box.
  63609. * doc :
  63610. */
  63611. setVisibilityBox(size: number): void;
  63612. /**
  63613. * Gets whether the PCS is always visible or not
  63614. * doc :
  63615. */
  63616. get isAlwaysVisible(): boolean;
  63617. /**
  63618. * Sets the PCS as always visible or not
  63619. * doc :
  63620. */
  63621. set isAlwaysVisible(val: boolean);
  63622. /**
  63623. * Tells to `setParticles()` to compute the particle rotations or not
  63624. * Default value : false. The PCS is faster when it's set to false
  63625. * Note : particle rotations are only applied to parent particles
  63626. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63627. */
  63628. set computeParticleRotation(val: boolean);
  63629. /**
  63630. * Tells to `setParticles()` to compute the particle colors or not.
  63631. * Default value : true. The PCS is faster when it's set to false.
  63632. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63633. */
  63634. set computeParticleColor(val: boolean);
  63635. set computeParticleTexture(val: boolean);
  63636. /**
  63637. * Gets if `setParticles()` computes the particle colors or not.
  63638. * Default value : false. The PCS is faster when it's set to false.
  63639. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63640. */
  63641. get computeParticleColor(): boolean;
  63642. /**
  63643. * Gets if `setParticles()` computes the particle textures or not.
  63644. * Default value : false. The PCS is faster when it's set to false.
  63645. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63646. */
  63647. get computeParticleTexture(): boolean;
  63648. /**
  63649. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63650. */
  63651. set computeBoundingBox(val: boolean);
  63652. /**
  63653. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63654. */
  63655. get computeBoundingBox(): boolean;
  63656. /**
  63657. * This function does nothing. It may be overwritten to set all the particle first values.
  63658. * The PCS doesn't call this function, you may have to call it by your own.
  63659. * doc :
  63660. */
  63661. initParticles(): void;
  63662. /**
  63663. * This function does nothing. It may be overwritten to recycle a particle
  63664. * The PCS doesn't call this function, you can to call it
  63665. * doc :
  63666. * @param particle The particle to recycle
  63667. * @returns the recycled particle
  63668. */
  63669. recycleParticle(particle: CloudPoint): CloudPoint;
  63670. /**
  63671. * Updates a particle : this function should be overwritten by the user.
  63672. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63673. * doc :
  63674. * @example : just set a particle position or velocity and recycle conditions
  63675. * @param particle The particle to update
  63676. * @returns the updated particle
  63677. */
  63678. updateParticle(particle: CloudPoint): CloudPoint;
  63679. /**
  63680. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63681. * This does nothing and may be overwritten by the user.
  63682. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63683. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63684. * @param update the boolean update value actually passed to setParticles()
  63685. */
  63686. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63687. /**
  63688. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63689. * This will be passed three parameters.
  63690. * This does nothing and may be overwritten by the user.
  63691. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63692. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63693. * @param update the boolean update value actually passed to setParticles()
  63694. */
  63695. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63696. }
  63697. }
  63698. declare module BABYLON {
  63699. /**
  63700. * Represents one particle of a points cloud system.
  63701. */
  63702. export class CloudPoint {
  63703. /**
  63704. * particle global index
  63705. */
  63706. idx: number;
  63707. /**
  63708. * The color of the particle
  63709. */
  63710. color: Nullable<Color4>;
  63711. /**
  63712. * The world space position of the particle.
  63713. */
  63714. position: Vector3;
  63715. /**
  63716. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63717. */
  63718. rotation: Vector3;
  63719. /**
  63720. * The world space rotation quaternion of the particle.
  63721. */
  63722. rotationQuaternion: Nullable<Quaternion>;
  63723. /**
  63724. * The uv of the particle.
  63725. */
  63726. uv: Nullable<Vector2>;
  63727. /**
  63728. * The current speed of the particle.
  63729. */
  63730. velocity: Vector3;
  63731. /**
  63732. * The pivot point in the particle local space.
  63733. */
  63734. pivot: Vector3;
  63735. /**
  63736. * Must the particle be translated from its pivot point in its local space ?
  63737. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63738. * Default : false
  63739. */
  63740. translateFromPivot: boolean;
  63741. /**
  63742. * Index of this particle in the global "positions" array (Internal use)
  63743. * @hidden
  63744. */
  63745. _pos: number;
  63746. /**
  63747. * @hidden Index of this particle in the global "indices" array (Internal use)
  63748. */
  63749. _ind: number;
  63750. /**
  63751. * Group this particle belongs to
  63752. */
  63753. _group: PointsGroup;
  63754. /**
  63755. * Group id of this particle
  63756. */
  63757. groupId: number;
  63758. /**
  63759. * Index of the particle in its group id (Internal use)
  63760. */
  63761. idxInGroup: number;
  63762. /**
  63763. * @hidden Particle BoundingInfo object (Internal use)
  63764. */
  63765. _boundingInfo: BoundingInfo;
  63766. /**
  63767. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63768. */
  63769. _pcs: PointsCloudSystem;
  63770. /**
  63771. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63772. */
  63773. _stillInvisible: boolean;
  63774. /**
  63775. * @hidden Last computed particle rotation matrix
  63776. */
  63777. _rotationMatrix: number[];
  63778. /**
  63779. * Parent particle Id, if any.
  63780. * Default null.
  63781. */
  63782. parentId: Nullable<number>;
  63783. /**
  63784. * @hidden Internal global position in the PCS.
  63785. */
  63786. _globalPosition: Vector3;
  63787. /**
  63788. * Creates a Point Cloud object.
  63789. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63790. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63791. * @param group (PointsGroup) is the group the particle belongs to
  63792. * @param groupId (integer) is the group identifier in the PCS.
  63793. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63794. * @param pcs defines the PCS it is associated to
  63795. */
  63796. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63797. /**
  63798. * get point size
  63799. */
  63800. get size(): Vector3;
  63801. /**
  63802. * Set point size
  63803. */
  63804. set size(scale: Vector3);
  63805. /**
  63806. * Legacy support, changed quaternion to rotationQuaternion
  63807. */
  63808. get quaternion(): Nullable<Quaternion>;
  63809. /**
  63810. * Legacy support, changed quaternion to rotationQuaternion
  63811. */
  63812. set quaternion(q: Nullable<Quaternion>);
  63813. /**
  63814. * Returns a boolean. True if the particle intersects a mesh, else false
  63815. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63816. * @param target is the object (point or mesh) what the intersection is computed against
  63817. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63818. * @returns true if it intersects
  63819. */
  63820. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63821. /**
  63822. * get the rotation matrix of the particle
  63823. * @hidden
  63824. */
  63825. getRotationMatrix(m: Matrix): void;
  63826. }
  63827. /**
  63828. * Represents a group of points in a points cloud system
  63829. * * PCS internal tool, don't use it manually.
  63830. */
  63831. export class PointsGroup {
  63832. /**
  63833. * The group id
  63834. * @hidden
  63835. */
  63836. groupID: number;
  63837. /**
  63838. * image data for group (internal use)
  63839. * @hidden
  63840. */
  63841. _groupImageData: Nullable<ArrayBufferView>;
  63842. /**
  63843. * Image Width (internal use)
  63844. * @hidden
  63845. */
  63846. _groupImgWidth: number;
  63847. /**
  63848. * Image Height (internal use)
  63849. * @hidden
  63850. */
  63851. _groupImgHeight: number;
  63852. /**
  63853. * Custom position function (internal use)
  63854. * @hidden
  63855. */
  63856. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63857. /**
  63858. * density per facet for surface points
  63859. * @hidden
  63860. */
  63861. _groupDensity: number[];
  63862. /**
  63863. * Only when points are colored by texture carries pointer to texture list array
  63864. * @hidden
  63865. */
  63866. _textureNb: number;
  63867. /**
  63868. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63869. * PCS internal tool, don't use it manually.
  63870. * @hidden
  63871. */
  63872. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63873. }
  63874. }
  63875. declare module BABYLON {
  63876. interface Scene {
  63877. /** @hidden (Backing field) */
  63878. _physicsEngine: Nullable<IPhysicsEngine>;
  63879. /** @hidden */
  63880. _physicsTimeAccumulator: number;
  63881. /**
  63882. * Gets the current physics engine
  63883. * @returns a IPhysicsEngine or null if none attached
  63884. */
  63885. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63886. /**
  63887. * Enables physics to the current scene
  63888. * @param gravity defines the scene's gravity for the physics engine
  63889. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63890. * @return a boolean indicating if the physics engine was initialized
  63891. */
  63892. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63893. /**
  63894. * Disables and disposes the physics engine associated with the scene
  63895. */
  63896. disablePhysicsEngine(): void;
  63897. /**
  63898. * Gets a boolean indicating if there is an active physics engine
  63899. * @returns a boolean indicating if there is an active physics engine
  63900. */
  63901. isPhysicsEnabled(): boolean;
  63902. /**
  63903. * Deletes a physics compound impostor
  63904. * @param compound defines the compound to delete
  63905. */
  63906. deleteCompoundImpostor(compound: any): void;
  63907. /**
  63908. * An event triggered when physic simulation is about to be run
  63909. */
  63910. onBeforePhysicsObservable: Observable<Scene>;
  63911. /**
  63912. * An event triggered when physic simulation has been done
  63913. */
  63914. onAfterPhysicsObservable: Observable<Scene>;
  63915. }
  63916. interface AbstractMesh {
  63917. /** @hidden */
  63918. _physicsImpostor: Nullable<PhysicsImpostor>;
  63919. /**
  63920. * Gets or sets impostor used for physic simulation
  63921. * @see http://doc.babylonjs.com/features/physics_engine
  63922. */
  63923. physicsImpostor: Nullable<PhysicsImpostor>;
  63924. /**
  63925. * Gets the current physics impostor
  63926. * @see http://doc.babylonjs.com/features/physics_engine
  63927. * @returns a physics impostor or null
  63928. */
  63929. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63930. /** Apply a physic impulse to the mesh
  63931. * @param force defines the force to apply
  63932. * @param contactPoint defines where to apply the force
  63933. * @returns the current mesh
  63934. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63935. */
  63936. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63937. /**
  63938. * Creates a physic joint between two meshes
  63939. * @param otherMesh defines the other mesh to use
  63940. * @param pivot1 defines the pivot to use on this mesh
  63941. * @param pivot2 defines the pivot to use on the other mesh
  63942. * @param options defines additional options (can be plugin dependent)
  63943. * @returns the current mesh
  63944. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63945. */
  63946. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63947. /** @hidden */
  63948. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63949. }
  63950. /**
  63951. * Defines the physics engine scene component responsible to manage a physics engine
  63952. */
  63953. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63954. /**
  63955. * The component name helpful to identify the component in the list of scene components.
  63956. */
  63957. readonly name: string;
  63958. /**
  63959. * The scene the component belongs to.
  63960. */
  63961. scene: Scene;
  63962. /**
  63963. * Creates a new instance of the component for the given scene
  63964. * @param scene Defines the scene to register the component in
  63965. */
  63966. constructor(scene: Scene);
  63967. /**
  63968. * Registers the component in a given scene
  63969. */
  63970. register(): void;
  63971. /**
  63972. * Rebuilds the elements related to this component in case of
  63973. * context lost for instance.
  63974. */
  63975. rebuild(): void;
  63976. /**
  63977. * Disposes the component and the associated ressources
  63978. */
  63979. dispose(): void;
  63980. }
  63981. }
  63982. declare module BABYLON {
  63983. /**
  63984. * A helper for physics simulations
  63985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63986. */
  63987. export class PhysicsHelper {
  63988. private _scene;
  63989. private _physicsEngine;
  63990. /**
  63991. * Initializes the Physics helper
  63992. * @param scene Babylon.js scene
  63993. */
  63994. constructor(scene: Scene);
  63995. /**
  63996. * Applies a radial explosion impulse
  63997. * @param origin the origin of the explosion
  63998. * @param radiusOrEventOptions the radius or the options of radial explosion
  63999. * @param strength the explosion strength
  64000. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64001. * @returns A physics radial explosion event, or null
  64002. */
  64003. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64004. /**
  64005. * Applies a radial explosion force
  64006. * @param origin the origin of the explosion
  64007. * @param radiusOrEventOptions the radius or the options of radial explosion
  64008. * @param strength the explosion strength
  64009. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64010. * @returns A physics radial explosion event, or null
  64011. */
  64012. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64013. /**
  64014. * Creates a gravitational field
  64015. * @param origin the origin of the explosion
  64016. * @param radiusOrEventOptions the radius or the options of radial explosion
  64017. * @param strength the explosion strength
  64018. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64019. * @returns A physics gravitational field event, or null
  64020. */
  64021. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64022. /**
  64023. * Creates a physics updraft event
  64024. * @param origin the origin of the updraft
  64025. * @param radiusOrEventOptions the radius or the options of the updraft
  64026. * @param strength the strength of the updraft
  64027. * @param height the height of the updraft
  64028. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64029. * @returns A physics updraft event, or null
  64030. */
  64031. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64032. /**
  64033. * Creates a physics vortex event
  64034. * @param origin the of the vortex
  64035. * @param radiusOrEventOptions the radius or the options of the vortex
  64036. * @param strength the strength of the vortex
  64037. * @param height the height of the vortex
  64038. * @returns a Physics vortex event, or null
  64039. * A physics vortex event or null
  64040. */
  64041. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64042. }
  64043. /**
  64044. * Represents a physics radial explosion event
  64045. */
  64046. class PhysicsRadialExplosionEvent {
  64047. private _scene;
  64048. private _options;
  64049. private _sphere;
  64050. private _dataFetched;
  64051. /**
  64052. * Initializes a radial explosioin event
  64053. * @param _scene BabylonJS scene
  64054. * @param _options The options for the vortex event
  64055. */
  64056. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64057. /**
  64058. * Returns the data related to the radial explosion event (sphere).
  64059. * @returns The radial explosion event data
  64060. */
  64061. getData(): PhysicsRadialExplosionEventData;
  64062. /**
  64063. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64064. * @param impostor A physics imposter
  64065. * @param origin the origin of the explosion
  64066. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64067. */
  64068. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64069. /**
  64070. * Triggers affecterd impostors callbacks
  64071. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64072. */
  64073. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64074. /**
  64075. * Disposes the sphere.
  64076. * @param force Specifies if the sphere should be disposed by force
  64077. */
  64078. dispose(force?: boolean): void;
  64079. /*** Helpers ***/
  64080. private _prepareSphere;
  64081. private _intersectsWithSphere;
  64082. }
  64083. /**
  64084. * Represents a gravitational field event
  64085. */
  64086. class PhysicsGravitationalFieldEvent {
  64087. private _physicsHelper;
  64088. private _scene;
  64089. private _origin;
  64090. private _options;
  64091. private _tickCallback;
  64092. private _sphere;
  64093. private _dataFetched;
  64094. /**
  64095. * Initializes the physics gravitational field event
  64096. * @param _physicsHelper A physics helper
  64097. * @param _scene BabylonJS scene
  64098. * @param _origin The origin position of the gravitational field event
  64099. * @param _options The options for the vortex event
  64100. */
  64101. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64102. /**
  64103. * Returns the data related to the gravitational field event (sphere).
  64104. * @returns A gravitational field event
  64105. */
  64106. getData(): PhysicsGravitationalFieldEventData;
  64107. /**
  64108. * Enables the gravitational field.
  64109. */
  64110. enable(): void;
  64111. /**
  64112. * Disables the gravitational field.
  64113. */
  64114. disable(): void;
  64115. /**
  64116. * Disposes the sphere.
  64117. * @param force The force to dispose from the gravitational field event
  64118. */
  64119. dispose(force?: boolean): void;
  64120. private _tick;
  64121. }
  64122. /**
  64123. * Represents a physics updraft event
  64124. */
  64125. class PhysicsUpdraftEvent {
  64126. private _scene;
  64127. private _origin;
  64128. private _options;
  64129. private _physicsEngine;
  64130. private _originTop;
  64131. private _originDirection;
  64132. private _tickCallback;
  64133. private _cylinder;
  64134. private _cylinderPosition;
  64135. private _dataFetched;
  64136. /**
  64137. * Initializes the physics updraft event
  64138. * @param _scene BabylonJS scene
  64139. * @param _origin The origin position of the updraft
  64140. * @param _options The options for the updraft event
  64141. */
  64142. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64143. /**
  64144. * Returns the data related to the updraft event (cylinder).
  64145. * @returns A physics updraft event
  64146. */
  64147. getData(): PhysicsUpdraftEventData;
  64148. /**
  64149. * Enables the updraft.
  64150. */
  64151. enable(): void;
  64152. /**
  64153. * Disables the updraft.
  64154. */
  64155. disable(): void;
  64156. /**
  64157. * Disposes the cylinder.
  64158. * @param force Specifies if the updraft should be disposed by force
  64159. */
  64160. dispose(force?: boolean): void;
  64161. private getImpostorHitData;
  64162. private _tick;
  64163. /*** Helpers ***/
  64164. private _prepareCylinder;
  64165. private _intersectsWithCylinder;
  64166. }
  64167. /**
  64168. * Represents a physics vortex event
  64169. */
  64170. class PhysicsVortexEvent {
  64171. private _scene;
  64172. private _origin;
  64173. private _options;
  64174. private _physicsEngine;
  64175. private _originTop;
  64176. private _tickCallback;
  64177. private _cylinder;
  64178. private _cylinderPosition;
  64179. private _dataFetched;
  64180. /**
  64181. * Initializes the physics vortex event
  64182. * @param _scene The BabylonJS scene
  64183. * @param _origin The origin position of the vortex
  64184. * @param _options The options for the vortex event
  64185. */
  64186. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64187. /**
  64188. * Returns the data related to the vortex event (cylinder).
  64189. * @returns The physics vortex event data
  64190. */
  64191. getData(): PhysicsVortexEventData;
  64192. /**
  64193. * Enables the vortex.
  64194. */
  64195. enable(): void;
  64196. /**
  64197. * Disables the cortex.
  64198. */
  64199. disable(): void;
  64200. /**
  64201. * Disposes the sphere.
  64202. * @param force
  64203. */
  64204. dispose(force?: boolean): void;
  64205. private getImpostorHitData;
  64206. private _tick;
  64207. /*** Helpers ***/
  64208. private _prepareCylinder;
  64209. private _intersectsWithCylinder;
  64210. }
  64211. /**
  64212. * Options fot the radial explosion event
  64213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64214. */
  64215. export class PhysicsRadialExplosionEventOptions {
  64216. /**
  64217. * The radius of the sphere for the radial explosion.
  64218. */
  64219. radius: number;
  64220. /**
  64221. * The strenth of the explosion.
  64222. */
  64223. strength: number;
  64224. /**
  64225. * The strenght of the force in correspondence to the distance of the affected object
  64226. */
  64227. falloff: PhysicsRadialImpulseFalloff;
  64228. /**
  64229. * Sphere options for the radial explosion.
  64230. */
  64231. sphere: {
  64232. segments: number;
  64233. diameter: number;
  64234. };
  64235. /**
  64236. * Sphere options for the radial explosion.
  64237. */
  64238. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64239. }
  64240. /**
  64241. * Options fot the updraft event
  64242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64243. */
  64244. export class PhysicsUpdraftEventOptions {
  64245. /**
  64246. * The radius of the cylinder for the vortex
  64247. */
  64248. radius: number;
  64249. /**
  64250. * The strenth of the updraft.
  64251. */
  64252. strength: number;
  64253. /**
  64254. * The height of the cylinder for the updraft.
  64255. */
  64256. height: number;
  64257. /**
  64258. * The mode for the the updraft.
  64259. */
  64260. updraftMode: PhysicsUpdraftMode;
  64261. }
  64262. /**
  64263. * Options fot the vortex event
  64264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64265. */
  64266. export class PhysicsVortexEventOptions {
  64267. /**
  64268. * The radius of the cylinder for the vortex
  64269. */
  64270. radius: number;
  64271. /**
  64272. * The strenth of the vortex.
  64273. */
  64274. strength: number;
  64275. /**
  64276. * The height of the cylinder for the vortex.
  64277. */
  64278. height: number;
  64279. /**
  64280. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64281. */
  64282. centripetalForceThreshold: number;
  64283. /**
  64284. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64285. */
  64286. centripetalForceMultiplier: number;
  64287. /**
  64288. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64289. */
  64290. centrifugalForceMultiplier: number;
  64291. /**
  64292. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64293. */
  64294. updraftForceMultiplier: number;
  64295. }
  64296. /**
  64297. * The strenght of the force in correspondence to the distance of the affected object
  64298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64299. */
  64300. export enum PhysicsRadialImpulseFalloff {
  64301. /** Defines that impulse is constant in strength across it's whole radius */
  64302. Constant = 0,
  64303. /** Defines that impulse gets weaker if it's further from the origin */
  64304. Linear = 1
  64305. }
  64306. /**
  64307. * The strength of the force in correspondence to the distance of the affected object
  64308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64309. */
  64310. export enum PhysicsUpdraftMode {
  64311. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64312. Center = 0,
  64313. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64314. Perpendicular = 1
  64315. }
  64316. /**
  64317. * Interface for a physics hit data
  64318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64319. */
  64320. export interface PhysicsHitData {
  64321. /**
  64322. * The force applied at the contact point
  64323. */
  64324. force: Vector3;
  64325. /**
  64326. * The contact point
  64327. */
  64328. contactPoint: Vector3;
  64329. /**
  64330. * The distance from the origin to the contact point
  64331. */
  64332. distanceFromOrigin: number;
  64333. }
  64334. /**
  64335. * Interface for radial explosion event data
  64336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64337. */
  64338. export interface PhysicsRadialExplosionEventData {
  64339. /**
  64340. * A sphere used for the radial explosion event
  64341. */
  64342. sphere: Mesh;
  64343. }
  64344. /**
  64345. * Interface for gravitational field event data
  64346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64347. */
  64348. export interface PhysicsGravitationalFieldEventData {
  64349. /**
  64350. * A sphere mesh used for the gravitational field event
  64351. */
  64352. sphere: Mesh;
  64353. }
  64354. /**
  64355. * Interface for updraft event data
  64356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64357. */
  64358. export interface PhysicsUpdraftEventData {
  64359. /**
  64360. * A cylinder used for the updraft event
  64361. */
  64362. cylinder: Mesh;
  64363. }
  64364. /**
  64365. * Interface for vortex event data
  64366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64367. */
  64368. export interface PhysicsVortexEventData {
  64369. /**
  64370. * A cylinder used for the vortex event
  64371. */
  64372. cylinder: Mesh;
  64373. }
  64374. /**
  64375. * Interface for an affected physics impostor
  64376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64377. */
  64378. export interface PhysicsAffectedImpostorWithData {
  64379. /**
  64380. * The impostor affected by the effect
  64381. */
  64382. impostor: PhysicsImpostor;
  64383. /**
  64384. * The data about the hit/horce from the explosion
  64385. */
  64386. hitData: PhysicsHitData;
  64387. }
  64388. }
  64389. declare module BABYLON {
  64390. /** @hidden */
  64391. export var blackAndWhitePixelShader: {
  64392. name: string;
  64393. shader: string;
  64394. };
  64395. }
  64396. declare module BABYLON {
  64397. /**
  64398. * Post process used to render in black and white
  64399. */
  64400. export class BlackAndWhitePostProcess extends PostProcess {
  64401. /**
  64402. * Linear about to convert he result to black and white (default: 1)
  64403. */
  64404. degree: number;
  64405. /**
  64406. * Creates a black and white post process
  64407. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64408. * @param name The name of the effect.
  64409. * @param options The required width/height ratio to downsize to before computing the render pass.
  64410. * @param camera The camera to apply the render pass to.
  64411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64412. * @param engine The engine which the post process will be applied. (default: current engine)
  64413. * @param reusable If the post process can be reused on the same frame. (default: false)
  64414. */
  64415. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64416. }
  64417. }
  64418. declare module BABYLON {
  64419. /**
  64420. * This represents a set of one or more post processes in Babylon.
  64421. * A post process can be used to apply a shader to a texture after it is rendered.
  64422. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64423. */
  64424. export class PostProcessRenderEffect {
  64425. private _postProcesses;
  64426. private _getPostProcesses;
  64427. private _singleInstance;
  64428. private _cameras;
  64429. private _indicesForCamera;
  64430. /**
  64431. * Name of the effect
  64432. * @hidden
  64433. */
  64434. _name: string;
  64435. /**
  64436. * Instantiates a post process render effect.
  64437. * A post process can be used to apply a shader to a texture after it is rendered.
  64438. * @param engine The engine the effect is tied to
  64439. * @param name The name of the effect
  64440. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64441. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64442. */
  64443. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64444. /**
  64445. * Checks if all the post processes in the effect are supported.
  64446. */
  64447. get isSupported(): boolean;
  64448. /**
  64449. * Updates the current state of the effect
  64450. * @hidden
  64451. */
  64452. _update(): void;
  64453. /**
  64454. * Attaches the effect on cameras
  64455. * @param cameras The camera to attach to.
  64456. * @hidden
  64457. */
  64458. _attachCameras(cameras: Camera): void;
  64459. /**
  64460. * Attaches the effect on cameras
  64461. * @param cameras The camera to attach to.
  64462. * @hidden
  64463. */
  64464. _attachCameras(cameras: Camera[]): void;
  64465. /**
  64466. * Detaches the effect on cameras
  64467. * @param cameras The camera to detatch from.
  64468. * @hidden
  64469. */
  64470. _detachCameras(cameras: Camera): void;
  64471. /**
  64472. * Detatches the effect on cameras
  64473. * @param cameras The camera to detatch from.
  64474. * @hidden
  64475. */
  64476. _detachCameras(cameras: Camera[]): void;
  64477. /**
  64478. * Enables the effect on given cameras
  64479. * @param cameras The camera to enable.
  64480. * @hidden
  64481. */
  64482. _enable(cameras: Camera): void;
  64483. /**
  64484. * Enables the effect on given cameras
  64485. * @param cameras The camera to enable.
  64486. * @hidden
  64487. */
  64488. _enable(cameras: Nullable<Camera[]>): void;
  64489. /**
  64490. * Disables the effect on the given cameras
  64491. * @param cameras The camera to disable.
  64492. * @hidden
  64493. */
  64494. _disable(cameras: Camera): void;
  64495. /**
  64496. * Disables the effect on the given cameras
  64497. * @param cameras The camera to disable.
  64498. * @hidden
  64499. */
  64500. _disable(cameras: Nullable<Camera[]>): void;
  64501. /**
  64502. * Gets a list of the post processes contained in the effect.
  64503. * @param camera The camera to get the post processes on.
  64504. * @returns The list of the post processes in the effect.
  64505. */
  64506. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64507. }
  64508. }
  64509. declare module BABYLON {
  64510. /** @hidden */
  64511. export var extractHighlightsPixelShader: {
  64512. name: string;
  64513. shader: string;
  64514. };
  64515. }
  64516. declare module BABYLON {
  64517. /**
  64518. * 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.
  64519. */
  64520. export class ExtractHighlightsPostProcess extends PostProcess {
  64521. /**
  64522. * The luminance threshold, pixels below this value will be set to black.
  64523. */
  64524. threshold: number;
  64525. /** @hidden */
  64526. _exposure: number;
  64527. /**
  64528. * Post process which has the input texture to be used when performing highlight extraction
  64529. * @hidden
  64530. */
  64531. _inputPostProcess: Nullable<PostProcess>;
  64532. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64533. }
  64534. }
  64535. declare module BABYLON {
  64536. /** @hidden */
  64537. export var bloomMergePixelShader: {
  64538. name: string;
  64539. shader: string;
  64540. };
  64541. }
  64542. declare module BABYLON {
  64543. /**
  64544. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64545. */
  64546. export class BloomMergePostProcess extends PostProcess {
  64547. /** Weight of the bloom to be added to the original input. */
  64548. weight: number;
  64549. /**
  64550. * Creates a new instance of @see BloomMergePostProcess
  64551. * @param name The name of the effect.
  64552. * @param originalFromInput Post process which's input will be used for the merge.
  64553. * @param blurred Blurred highlights post process which's output will be used.
  64554. * @param weight Weight of the bloom to be added to the original input.
  64555. * @param options The required width/height ratio to downsize to before computing the render pass.
  64556. * @param camera The camera to apply the render pass to.
  64557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64558. * @param engine The engine which the post process will be applied. (default: current engine)
  64559. * @param reusable If the post process can be reused on the same frame. (default: false)
  64560. * @param textureType Type of textures used when performing the post process. (default: 0)
  64561. * @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)
  64562. */
  64563. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64564. /** Weight of the bloom to be added to the original input. */
  64565. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64566. }
  64567. }
  64568. declare module BABYLON {
  64569. /**
  64570. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64571. */
  64572. export class BloomEffect extends PostProcessRenderEffect {
  64573. private bloomScale;
  64574. /**
  64575. * @hidden Internal
  64576. */
  64577. _effects: Array<PostProcess>;
  64578. /**
  64579. * @hidden Internal
  64580. */
  64581. _downscale: ExtractHighlightsPostProcess;
  64582. private _blurX;
  64583. private _blurY;
  64584. private _merge;
  64585. /**
  64586. * The luminance threshold to find bright areas of the image to bloom.
  64587. */
  64588. get threshold(): number;
  64589. set threshold(value: number);
  64590. /**
  64591. * The strength of the bloom.
  64592. */
  64593. get weight(): number;
  64594. set weight(value: number);
  64595. /**
  64596. * Specifies the size of the bloom blur kernel, relative to the final output size
  64597. */
  64598. get kernel(): number;
  64599. set kernel(value: number);
  64600. /**
  64601. * Creates a new instance of @see BloomEffect
  64602. * @param scene The scene the effect belongs to.
  64603. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64604. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64605. * @param bloomWeight The the strength of bloom.
  64606. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64607. * @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)
  64608. */
  64609. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64610. /**
  64611. * Disposes each of the internal effects for a given camera.
  64612. * @param camera The camera to dispose the effect on.
  64613. */
  64614. disposeEffects(camera: Camera): void;
  64615. /**
  64616. * @hidden Internal
  64617. */
  64618. _updateEffects(): void;
  64619. /**
  64620. * Internal
  64621. * @returns if all the contained post processes are ready.
  64622. * @hidden
  64623. */
  64624. _isReady(): boolean;
  64625. }
  64626. }
  64627. declare module BABYLON {
  64628. /** @hidden */
  64629. export var chromaticAberrationPixelShader: {
  64630. name: string;
  64631. shader: string;
  64632. };
  64633. }
  64634. declare module BABYLON {
  64635. /**
  64636. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64637. */
  64638. export class ChromaticAberrationPostProcess extends PostProcess {
  64639. /**
  64640. * The amount of seperation of rgb channels (default: 30)
  64641. */
  64642. aberrationAmount: number;
  64643. /**
  64644. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64645. */
  64646. radialIntensity: number;
  64647. /**
  64648. * 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))
  64649. */
  64650. direction: Vector2;
  64651. /**
  64652. * 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))
  64653. */
  64654. centerPosition: Vector2;
  64655. /**
  64656. * Creates a new instance ChromaticAberrationPostProcess
  64657. * @param name The name of the effect.
  64658. * @param screenWidth The width of the screen to apply the effect on.
  64659. * @param screenHeight The height of the screen to apply the effect on.
  64660. * @param options The required width/height ratio to downsize to before computing the render pass.
  64661. * @param camera The camera to apply the render pass to.
  64662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64663. * @param engine The engine which the post process will be applied. (default: current engine)
  64664. * @param reusable If the post process can be reused on the same frame. (default: false)
  64665. * @param textureType Type of textures used when performing the post process. (default: 0)
  64666. * @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)
  64667. */
  64668. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64669. }
  64670. }
  64671. declare module BABYLON {
  64672. /** @hidden */
  64673. export var circleOfConfusionPixelShader: {
  64674. name: string;
  64675. shader: string;
  64676. };
  64677. }
  64678. declare module BABYLON {
  64679. /**
  64680. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64681. */
  64682. export class CircleOfConfusionPostProcess extends PostProcess {
  64683. /**
  64684. * 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.
  64685. */
  64686. lensSize: number;
  64687. /**
  64688. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64689. */
  64690. fStop: number;
  64691. /**
  64692. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64693. */
  64694. focusDistance: number;
  64695. /**
  64696. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64697. */
  64698. focalLength: number;
  64699. private _depthTexture;
  64700. /**
  64701. * Creates a new instance CircleOfConfusionPostProcess
  64702. * @param name The name of the effect.
  64703. * @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.
  64704. * @param options The required width/height ratio to downsize to before computing the render pass.
  64705. * @param camera The camera to apply the render pass to.
  64706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64707. * @param engine The engine which the post process will be applied. (default: current engine)
  64708. * @param reusable If the post process can be reused on the same frame. (default: false)
  64709. * @param textureType Type of textures used when performing the post process. (default: 0)
  64710. * @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)
  64711. */
  64712. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64713. /**
  64714. * 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.
  64715. */
  64716. set depthTexture(value: RenderTargetTexture);
  64717. }
  64718. }
  64719. declare module BABYLON {
  64720. /** @hidden */
  64721. export var colorCorrectionPixelShader: {
  64722. name: string;
  64723. shader: string;
  64724. };
  64725. }
  64726. declare module BABYLON {
  64727. /**
  64728. *
  64729. * This post-process allows the modification of rendered colors by using
  64730. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64731. *
  64732. * The object needs to be provided an url to a texture containing the color
  64733. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64734. * Use an image editing software to tweak the LUT to match your needs.
  64735. *
  64736. * For an example of a color LUT, see here:
  64737. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64738. * For explanations on color grading, see here:
  64739. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64740. *
  64741. */
  64742. export class ColorCorrectionPostProcess extends PostProcess {
  64743. private _colorTableTexture;
  64744. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64745. }
  64746. }
  64747. declare module BABYLON {
  64748. /** @hidden */
  64749. export var convolutionPixelShader: {
  64750. name: string;
  64751. shader: string;
  64752. };
  64753. }
  64754. declare module BABYLON {
  64755. /**
  64756. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64757. * input texture to perform effects such as edge detection or sharpening
  64758. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64759. */
  64760. export class ConvolutionPostProcess extends PostProcess {
  64761. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64762. kernel: number[];
  64763. /**
  64764. * Creates a new instance ConvolutionPostProcess
  64765. * @param name The name of the effect.
  64766. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64767. * @param options The required width/height ratio to downsize to before computing the render pass.
  64768. * @param camera The camera to apply the render pass to.
  64769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64770. * @param engine The engine which the post process will be applied. (default: current engine)
  64771. * @param reusable If the post process can be reused on the same frame. (default: false)
  64772. * @param textureType Type of textures used when performing the post process. (default: 0)
  64773. */
  64774. constructor(name: string,
  64775. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64776. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64777. /**
  64778. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64779. */
  64780. static EdgeDetect0Kernel: number[];
  64781. /**
  64782. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64783. */
  64784. static EdgeDetect1Kernel: number[];
  64785. /**
  64786. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64787. */
  64788. static EdgeDetect2Kernel: number[];
  64789. /**
  64790. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64791. */
  64792. static SharpenKernel: number[];
  64793. /**
  64794. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64795. */
  64796. static EmbossKernel: number[];
  64797. /**
  64798. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64799. */
  64800. static GaussianKernel: number[];
  64801. }
  64802. }
  64803. declare module BABYLON {
  64804. /**
  64805. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64806. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64807. * based on samples that have a large difference in distance than the center pixel.
  64808. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64809. */
  64810. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64811. direction: Vector2;
  64812. /**
  64813. * Creates a new instance CircleOfConfusionPostProcess
  64814. * @param name The name of the effect.
  64815. * @param scene The scene the effect belongs to.
  64816. * @param direction The direction the blur should be applied.
  64817. * @param kernel The size of the kernel used to blur.
  64818. * @param options The required width/height ratio to downsize to before computing the render pass.
  64819. * @param camera The camera to apply the render pass to.
  64820. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64821. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64823. * @param engine The engine which the post process will be applied. (default: current engine)
  64824. * @param reusable If the post process can be reused on the same frame. (default: false)
  64825. * @param textureType Type of textures used when performing the post process. (default: 0)
  64826. * @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)
  64827. */
  64828. 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);
  64829. }
  64830. }
  64831. declare module BABYLON {
  64832. /** @hidden */
  64833. export var depthOfFieldMergePixelShader: {
  64834. name: string;
  64835. shader: string;
  64836. };
  64837. }
  64838. declare module BABYLON {
  64839. /**
  64840. * Options to be set when merging outputs from the default pipeline.
  64841. */
  64842. export class DepthOfFieldMergePostProcessOptions {
  64843. /**
  64844. * The original image to merge on top of
  64845. */
  64846. originalFromInput: PostProcess;
  64847. /**
  64848. * Parameters to perform the merge of the depth of field effect
  64849. */
  64850. depthOfField?: {
  64851. circleOfConfusion: PostProcess;
  64852. blurSteps: Array<PostProcess>;
  64853. };
  64854. /**
  64855. * Parameters to perform the merge of bloom effect
  64856. */
  64857. bloom?: {
  64858. blurred: PostProcess;
  64859. weight: number;
  64860. };
  64861. }
  64862. /**
  64863. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64864. */
  64865. export class DepthOfFieldMergePostProcess extends PostProcess {
  64866. private blurSteps;
  64867. /**
  64868. * Creates a new instance of DepthOfFieldMergePostProcess
  64869. * @param name The name of the effect.
  64870. * @param originalFromInput Post process which's input will be used for the merge.
  64871. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64872. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64873. * @param options The required width/height ratio to downsize to before computing the render pass.
  64874. * @param camera The camera to apply the render pass to.
  64875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64876. * @param engine The engine which the post process will be applied. (default: current engine)
  64877. * @param reusable If the post process can be reused on the same frame. (default: false)
  64878. * @param textureType Type of textures used when performing the post process. (default: 0)
  64879. * @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)
  64880. */
  64881. 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);
  64882. /**
  64883. * Updates the effect with the current post process compile time values and recompiles the shader.
  64884. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64885. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64886. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64887. * @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
  64888. * @param onCompiled Called when the shader has been compiled.
  64889. * @param onError Called if there is an error when compiling a shader.
  64890. */
  64891. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64892. }
  64893. }
  64894. declare module BABYLON {
  64895. /**
  64896. * Specifies the level of max blur that should be applied when using the depth of field effect
  64897. */
  64898. export enum DepthOfFieldEffectBlurLevel {
  64899. /**
  64900. * Subtle blur
  64901. */
  64902. Low = 0,
  64903. /**
  64904. * Medium blur
  64905. */
  64906. Medium = 1,
  64907. /**
  64908. * Large blur
  64909. */
  64910. High = 2
  64911. }
  64912. /**
  64913. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64914. */
  64915. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64916. private _circleOfConfusion;
  64917. /**
  64918. * @hidden Internal, blurs from high to low
  64919. */
  64920. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64921. private _depthOfFieldBlurY;
  64922. private _dofMerge;
  64923. /**
  64924. * @hidden Internal post processes in depth of field effect
  64925. */
  64926. _effects: Array<PostProcess>;
  64927. /**
  64928. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64929. */
  64930. set focalLength(value: number);
  64931. get focalLength(): number;
  64932. /**
  64933. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64934. */
  64935. set fStop(value: number);
  64936. get fStop(): number;
  64937. /**
  64938. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64939. */
  64940. set focusDistance(value: number);
  64941. get focusDistance(): number;
  64942. /**
  64943. * 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.
  64944. */
  64945. set lensSize(value: number);
  64946. get lensSize(): number;
  64947. /**
  64948. * Creates a new instance DepthOfFieldEffect
  64949. * @param scene The scene the effect belongs to.
  64950. * @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.
  64951. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64952. * @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)
  64953. */
  64954. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64955. /**
  64956. * Get the current class name of the current effet
  64957. * @returns "DepthOfFieldEffect"
  64958. */
  64959. getClassName(): string;
  64960. /**
  64961. * 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.
  64962. */
  64963. set depthTexture(value: RenderTargetTexture);
  64964. /**
  64965. * Disposes each of the internal effects for a given camera.
  64966. * @param camera The camera to dispose the effect on.
  64967. */
  64968. disposeEffects(camera: Camera): void;
  64969. /**
  64970. * @hidden Internal
  64971. */
  64972. _updateEffects(): void;
  64973. /**
  64974. * Internal
  64975. * @returns if all the contained post processes are ready.
  64976. * @hidden
  64977. */
  64978. _isReady(): boolean;
  64979. }
  64980. }
  64981. declare module BABYLON {
  64982. /** @hidden */
  64983. export var displayPassPixelShader: {
  64984. name: string;
  64985. shader: string;
  64986. };
  64987. }
  64988. declare module BABYLON {
  64989. /**
  64990. * DisplayPassPostProcess which produces an output the same as it's input
  64991. */
  64992. export class DisplayPassPostProcess extends PostProcess {
  64993. /**
  64994. * Creates the DisplayPassPostProcess
  64995. * @param name The name of the effect.
  64996. * @param options The required width/height ratio to downsize to before computing the render pass.
  64997. * @param camera The camera to apply the render pass to.
  64998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64999. * @param engine The engine which the post process will be applied. (default: current engine)
  65000. * @param reusable If the post process can be reused on the same frame. (default: false)
  65001. */
  65002. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65003. }
  65004. }
  65005. declare module BABYLON {
  65006. /** @hidden */
  65007. export var filterPixelShader: {
  65008. name: string;
  65009. shader: string;
  65010. };
  65011. }
  65012. declare module BABYLON {
  65013. /**
  65014. * Applies a kernel filter to the image
  65015. */
  65016. export class FilterPostProcess extends PostProcess {
  65017. /** The matrix to be applied to the image */
  65018. kernelMatrix: Matrix;
  65019. /**
  65020. *
  65021. * @param name The name of the effect.
  65022. * @param kernelMatrix The matrix to be applied to the image
  65023. * @param options The required width/height ratio to downsize to before computing the render pass.
  65024. * @param camera The camera to apply the render pass to.
  65025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65026. * @param engine The engine which the post process will be applied. (default: current engine)
  65027. * @param reusable If the post process can be reused on the same frame. (default: false)
  65028. */
  65029. constructor(name: string,
  65030. /** The matrix to be applied to the image */
  65031. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65032. }
  65033. }
  65034. declare module BABYLON {
  65035. /** @hidden */
  65036. export var fxaaPixelShader: {
  65037. name: string;
  65038. shader: string;
  65039. };
  65040. }
  65041. declare module BABYLON {
  65042. /** @hidden */
  65043. export var fxaaVertexShader: {
  65044. name: string;
  65045. shader: string;
  65046. };
  65047. }
  65048. declare module BABYLON {
  65049. /**
  65050. * Fxaa post process
  65051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65052. */
  65053. export class FxaaPostProcess extends PostProcess {
  65054. /** @hidden */
  65055. texelWidth: number;
  65056. /** @hidden */
  65057. texelHeight: number;
  65058. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65059. private _getDefines;
  65060. }
  65061. }
  65062. declare module BABYLON {
  65063. /** @hidden */
  65064. export var grainPixelShader: {
  65065. name: string;
  65066. shader: string;
  65067. };
  65068. }
  65069. declare module BABYLON {
  65070. /**
  65071. * The GrainPostProcess adds noise to the image at mid luminance levels
  65072. */
  65073. export class GrainPostProcess extends PostProcess {
  65074. /**
  65075. * The intensity of the grain added (default: 30)
  65076. */
  65077. intensity: number;
  65078. /**
  65079. * If the grain should be randomized on every frame
  65080. */
  65081. animated: boolean;
  65082. /**
  65083. * Creates a new instance of @see GrainPostProcess
  65084. * @param name The name of the effect.
  65085. * @param options The required width/height ratio to downsize to before computing the render pass.
  65086. * @param camera The camera to apply the render pass to.
  65087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65088. * @param engine The engine which the post process will be applied. (default: current engine)
  65089. * @param reusable If the post process can be reused on the same frame. (default: false)
  65090. * @param textureType Type of textures used when performing the post process. (default: 0)
  65091. * @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)
  65092. */
  65093. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65094. }
  65095. }
  65096. declare module BABYLON {
  65097. /** @hidden */
  65098. export var highlightsPixelShader: {
  65099. name: string;
  65100. shader: string;
  65101. };
  65102. }
  65103. declare module BABYLON {
  65104. /**
  65105. * Extracts highlights from the image
  65106. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65107. */
  65108. export class HighlightsPostProcess extends PostProcess {
  65109. /**
  65110. * Extracts highlights from the image
  65111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65112. * @param name The name of the effect.
  65113. * @param options The required width/height ratio to downsize to before computing the render pass.
  65114. * @param camera The camera to apply the render pass to.
  65115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65116. * @param engine The engine which the post process will be applied. (default: current engine)
  65117. * @param reusable If the post process can be reused on the same frame. (default: false)
  65118. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65119. */
  65120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65121. }
  65122. }
  65123. declare module BABYLON {
  65124. /** @hidden */
  65125. export var mrtFragmentDeclaration: {
  65126. name: string;
  65127. shader: string;
  65128. };
  65129. }
  65130. declare module BABYLON {
  65131. /** @hidden */
  65132. export var geometryPixelShader: {
  65133. name: string;
  65134. shader: string;
  65135. };
  65136. }
  65137. declare module BABYLON {
  65138. /** @hidden */
  65139. export var geometryVertexShader: {
  65140. name: string;
  65141. shader: string;
  65142. };
  65143. }
  65144. declare module BABYLON {
  65145. /** @hidden */
  65146. interface ISavedTransformationMatrix {
  65147. world: Matrix;
  65148. viewProjection: Matrix;
  65149. }
  65150. /**
  65151. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65152. */
  65153. export class GeometryBufferRenderer {
  65154. /**
  65155. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65156. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65157. */
  65158. static readonly POSITION_TEXTURE_TYPE: number;
  65159. /**
  65160. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65161. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65162. */
  65163. static readonly VELOCITY_TEXTURE_TYPE: number;
  65164. /**
  65165. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65166. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65167. */
  65168. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65169. /**
  65170. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65171. * in order to compute objects velocities when enableVelocity is set to "true"
  65172. * @hidden
  65173. */
  65174. _previousTransformationMatrices: {
  65175. [index: number]: ISavedTransformationMatrix;
  65176. };
  65177. /**
  65178. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65179. * in order to compute objects velocities when enableVelocity is set to "true"
  65180. * @hidden
  65181. */
  65182. _previousBonesTransformationMatrices: {
  65183. [index: number]: Float32Array;
  65184. };
  65185. /**
  65186. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65187. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65188. */
  65189. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65190. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65191. renderTransparentMeshes: boolean;
  65192. private _scene;
  65193. private _multiRenderTarget;
  65194. private _ratio;
  65195. private _enablePosition;
  65196. private _enableVelocity;
  65197. private _enableReflectivity;
  65198. private _positionIndex;
  65199. private _velocityIndex;
  65200. private _reflectivityIndex;
  65201. protected _effect: Effect;
  65202. protected _cachedDefines: string;
  65203. /**
  65204. * Set the render list (meshes to be rendered) used in the G buffer.
  65205. */
  65206. set renderList(meshes: Mesh[]);
  65207. /**
  65208. * Gets wether or not G buffer are supported by the running hardware.
  65209. * This requires draw buffer supports
  65210. */
  65211. get isSupported(): boolean;
  65212. /**
  65213. * Returns the index of the given texture type in the G-Buffer textures array
  65214. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65215. * @returns the index of the given texture type in the G-Buffer textures array
  65216. */
  65217. getTextureIndex(textureType: number): number;
  65218. /**
  65219. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65220. */
  65221. get enablePosition(): boolean;
  65222. /**
  65223. * Sets whether or not objects positions are enabled for the G buffer.
  65224. */
  65225. set enablePosition(enable: boolean);
  65226. /**
  65227. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65228. */
  65229. get enableVelocity(): boolean;
  65230. /**
  65231. * Sets wether or not objects velocities are enabled for the G buffer.
  65232. */
  65233. set enableVelocity(enable: boolean);
  65234. /**
  65235. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65236. */
  65237. get enableReflectivity(): boolean;
  65238. /**
  65239. * Sets wether or not objects roughness are enabled for the G buffer.
  65240. */
  65241. set enableReflectivity(enable: boolean);
  65242. /**
  65243. * Gets the scene associated with the buffer.
  65244. */
  65245. get scene(): Scene;
  65246. /**
  65247. * Gets the ratio used by the buffer during its creation.
  65248. * How big is the buffer related to the main canvas.
  65249. */
  65250. get ratio(): number;
  65251. /** @hidden */
  65252. static _SceneComponentInitialization: (scene: Scene) => void;
  65253. /**
  65254. * Creates a new G Buffer for the scene
  65255. * @param scene The scene the buffer belongs to
  65256. * @param ratio How big is the buffer related to the main canvas.
  65257. */
  65258. constructor(scene: Scene, ratio?: number);
  65259. /**
  65260. * Checks wether everything is ready to render a submesh to the G buffer.
  65261. * @param subMesh the submesh to check readiness for
  65262. * @param useInstances is the mesh drawn using instance or not
  65263. * @returns true if ready otherwise false
  65264. */
  65265. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65266. /**
  65267. * Gets the current underlying G Buffer.
  65268. * @returns the buffer
  65269. */
  65270. getGBuffer(): MultiRenderTarget;
  65271. /**
  65272. * Gets the number of samples used to render the buffer (anti aliasing).
  65273. */
  65274. get samples(): number;
  65275. /**
  65276. * Sets the number of samples used to render the buffer (anti aliasing).
  65277. */
  65278. set samples(value: number);
  65279. /**
  65280. * Disposes the renderer and frees up associated resources.
  65281. */
  65282. dispose(): void;
  65283. protected _createRenderTargets(): void;
  65284. private _copyBonesTransformationMatrices;
  65285. }
  65286. }
  65287. declare module BABYLON {
  65288. interface Scene {
  65289. /** @hidden (Backing field) */
  65290. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65291. /**
  65292. * Gets or Sets the current geometry buffer associated to the scene.
  65293. */
  65294. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65295. /**
  65296. * Enables a GeometryBufferRender and associates it with the scene
  65297. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65298. * @returns the GeometryBufferRenderer
  65299. */
  65300. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65301. /**
  65302. * Disables the GeometryBufferRender associated with the scene
  65303. */
  65304. disableGeometryBufferRenderer(): void;
  65305. }
  65306. /**
  65307. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65308. * in several rendering techniques.
  65309. */
  65310. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65311. /**
  65312. * The component name helpful to identify the component in the list of scene components.
  65313. */
  65314. readonly name: string;
  65315. /**
  65316. * The scene the component belongs to.
  65317. */
  65318. scene: Scene;
  65319. /**
  65320. * Creates a new instance of the component for the given scene
  65321. * @param scene Defines the scene to register the component in
  65322. */
  65323. constructor(scene: Scene);
  65324. /**
  65325. * Registers the component in a given scene
  65326. */
  65327. register(): void;
  65328. /**
  65329. * Rebuilds the elements related to this component in case of
  65330. * context lost for instance.
  65331. */
  65332. rebuild(): void;
  65333. /**
  65334. * Disposes the component and the associated ressources
  65335. */
  65336. dispose(): void;
  65337. private _gatherRenderTargets;
  65338. }
  65339. }
  65340. declare module BABYLON {
  65341. /** @hidden */
  65342. export var motionBlurPixelShader: {
  65343. name: string;
  65344. shader: string;
  65345. };
  65346. }
  65347. declare module BABYLON {
  65348. /**
  65349. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65350. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65351. * As an example, all you have to do is to create the post-process:
  65352. * var mb = new BABYLON.MotionBlurPostProcess(
  65353. * 'mb', // The name of the effect.
  65354. * scene, // The scene containing the objects to blur according to their velocity.
  65355. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65356. * camera // The camera to apply the render pass to.
  65357. * );
  65358. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65359. */
  65360. export class MotionBlurPostProcess extends PostProcess {
  65361. /**
  65362. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65363. */
  65364. motionStrength: number;
  65365. /**
  65366. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65367. */
  65368. get motionBlurSamples(): number;
  65369. /**
  65370. * Sets the number of iterations to be used for motion blur quality
  65371. */
  65372. set motionBlurSamples(samples: number);
  65373. private _motionBlurSamples;
  65374. private _geometryBufferRenderer;
  65375. /**
  65376. * Creates a new instance MotionBlurPostProcess
  65377. * @param name The name of the effect.
  65378. * @param scene The scene containing the objects to blur according to their velocity.
  65379. * @param options The required width/height ratio to downsize to before computing the render pass.
  65380. * @param camera The camera to apply the render pass to.
  65381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65382. * @param engine The engine which the post process will be applied. (default: current engine)
  65383. * @param reusable If the post process can be reused on the same frame. (default: false)
  65384. * @param textureType Type of textures used when performing the post process. (default: 0)
  65385. * @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)
  65386. */
  65387. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65388. /**
  65389. * Excludes the given skinned mesh from computing bones velocities.
  65390. * 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.
  65391. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65392. */
  65393. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65394. /**
  65395. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65396. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65397. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65398. */
  65399. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65400. /**
  65401. * Disposes the post process.
  65402. * @param camera The camera to dispose the post process on.
  65403. */
  65404. dispose(camera?: Camera): void;
  65405. }
  65406. }
  65407. declare module BABYLON {
  65408. /** @hidden */
  65409. export var refractionPixelShader: {
  65410. name: string;
  65411. shader: string;
  65412. };
  65413. }
  65414. declare module BABYLON {
  65415. /**
  65416. * Post process which applies a refractin texture
  65417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65418. */
  65419. export class RefractionPostProcess extends PostProcess {
  65420. /** the base color of the refraction (used to taint the rendering) */
  65421. color: Color3;
  65422. /** simulated refraction depth */
  65423. depth: number;
  65424. /** the coefficient of the base color (0 to remove base color tainting) */
  65425. colorLevel: number;
  65426. private _refTexture;
  65427. private _ownRefractionTexture;
  65428. /**
  65429. * Gets or sets the refraction texture
  65430. * Please note that you are responsible for disposing the texture if you set it manually
  65431. */
  65432. get refractionTexture(): Texture;
  65433. set refractionTexture(value: Texture);
  65434. /**
  65435. * Initializes the RefractionPostProcess
  65436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65437. * @param name The name of the effect.
  65438. * @param refractionTextureUrl Url of the refraction texture to use
  65439. * @param color the base color of the refraction (used to taint the rendering)
  65440. * @param depth simulated refraction depth
  65441. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65442. * @param camera The camera to apply the render pass to.
  65443. * @param options The required width/height ratio to downsize to before computing the render pass.
  65444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65445. * @param engine The engine which the post process will be applied. (default: current engine)
  65446. * @param reusable If the post process can be reused on the same frame. (default: false)
  65447. */
  65448. constructor(name: string, refractionTextureUrl: string,
  65449. /** the base color of the refraction (used to taint the rendering) */
  65450. color: Color3,
  65451. /** simulated refraction depth */
  65452. depth: number,
  65453. /** the coefficient of the base color (0 to remove base color tainting) */
  65454. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65455. /**
  65456. * Disposes of the post process
  65457. * @param camera Camera to dispose post process on
  65458. */
  65459. dispose(camera: Camera): void;
  65460. }
  65461. }
  65462. declare module BABYLON {
  65463. /** @hidden */
  65464. export var sharpenPixelShader: {
  65465. name: string;
  65466. shader: string;
  65467. };
  65468. }
  65469. declare module BABYLON {
  65470. /**
  65471. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65472. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65473. */
  65474. export class SharpenPostProcess extends PostProcess {
  65475. /**
  65476. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65477. */
  65478. colorAmount: number;
  65479. /**
  65480. * How much sharpness should be applied (default: 0.3)
  65481. */
  65482. edgeAmount: number;
  65483. /**
  65484. * Creates a new instance ConvolutionPostProcess
  65485. * @param name The name of the effect.
  65486. * @param options The required width/height ratio to downsize to before computing the render pass.
  65487. * @param camera The camera to apply the render pass to.
  65488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65489. * @param engine The engine which the post process will be applied. (default: current engine)
  65490. * @param reusable If the post process can be reused on the same frame. (default: false)
  65491. * @param textureType Type of textures used when performing the post process. (default: 0)
  65492. * @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)
  65493. */
  65494. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65495. }
  65496. }
  65497. declare module BABYLON {
  65498. /**
  65499. * PostProcessRenderPipeline
  65500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65501. */
  65502. export class PostProcessRenderPipeline {
  65503. private engine;
  65504. private _renderEffects;
  65505. private _renderEffectsForIsolatedPass;
  65506. /**
  65507. * List of inspectable custom properties (used by the Inspector)
  65508. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65509. */
  65510. inspectableCustomProperties: IInspectable[];
  65511. /**
  65512. * @hidden
  65513. */
  65514. protected _cameras: Camera[];
  65515. /** @hidden */
  65516. _name: string;
  65517. /**
  65518. * Gets pipeline name
  65519. */
  65520. get name(): string;
  65521. /** Gets the list of attached cameras */
  65522. get cameras(): Camera[];
  65523. /**
  65524. * Initializes a PostProcessRenderPipeline
  65525. * @param engine engine to add the pipeline to
  65526. * @param name name of the pipeline
  65527. */
  65528. constructor(engine: Engine, name: string);
  65529. /**
  65530. * Gets the class name
  65531. * @returns "PostProcessRenderPipeline"
  65532. */
  65533. getClassName(): string;
  65534. /**
  65535. * If all the render effects in the pipeline are supported
  65536. */
  65537. get isSupported(): boolean;
  65538. /**
  65539. * Adds an effect to the pipeline
  65540. * @param renderEffect the effect to add
  65541. */
  65542. addEffect(renderEffect: PostProcessRenderEffect): void;
  65543. /** @hidden */
  65544. _rebuild(): void;
  65545. /** @hidden */
  65546. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65547. /** @hidden */
  65548. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65549. /** @hidden */
  65550. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65551. /** @hidden */
  65552. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65553. /** @hidden */
  65554. _attachCameras(cameras: Camera, unique: boolean): void;
  65555. /** @hidden */
  65556. _attachCameras(cameras: Camera[], unique: boolean): void;
  65557. /** @hidden */
  65558. _detachCameras(cameras: Camera): void;
  65559. /** @hidden */
  65560. _detachCameras(cameras: Nullable<Camera[]>): void;
  65561. /** @hidden */
  65562. _update(): void;
  65563. /** @hidden */
  65564. _reset(): void;
  65565. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65566. /**
  65567. * Disposes of the pipeline
  65568. */
  65569. dispose(): void;
  65570. }
  65571. }
  65572. declare module BABYLON {
  65573. /**
  65574. * PostProcessRenderPipelineManager class
  65575. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65576. */
  65577. export class PostProcessRenderPipelineManager {
  65578. private _renderPipelines;
  65579. /**
  65580. * Initializes a PostProcessRenderPipelineManager
  65581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65582. */
  65583. constructor();
  65584. /**
  65585. * Gets the list of supported render pipelines
  65586. */
  65587. get supportedPipelines(): PostProcessRenderPipeline[];
  65588. /**
  65589. * Adds a pipeline to the manager
  65590. * @param renderPipeline The pipeline to add
  65591. */
  65592. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65593. /**
  65594. * Attaches a camera to the pipeline
  65595. * @param renderPipelineName The name of the pipeline to attach to
  65596. * @param cameras the camera to attach
  65597. * @param unique if the camera can be attached multiple times to the pipeline
  65598. */
  65599. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65600. /**
  65601. * Detaches a camera from the pipeline
  65602. * @param renderPipelineName The name of the pipeline to detach from
  65603. * @param cameras the camera to detach
  65604. */
  65605. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65606. /**
  65607. * Enables an effect by name on a pipeline
  65608. * @param renderPipelineName the name of the pipeline to enable the effect in
  65609. * @param renderEffectName the name of the effect to enable
  65610. * @param cameras the cameras that the effect should be enabled on
  65611. */
  65612. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65613. /**
  65614. * Disables an effect by name on a pipeline
  65615. * @param renderPipelineName the name of the pipeline to disable the effect in
  65616. * @param renderEffectName the name of the effect to disable
  65617. * @param cameras the cameras that the effect should be disabled on
  65618. */
  65619. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65620. /**
  65621. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65622. */
  65623. update(): void;
  65624. /** @hidden */
  65625. _rebuild(): void;
  65626. /**
  65627. * Disposes of the manager and pipelines
  65628. */
  65629. dispose(): void;
  65630. }
  65631. }
  65632. declare module BABYLON {
  65633. interface Scene {
  65634. /** @hidden (Backing field) */
  65635. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65636. /**
  65637. * Gets the postprocess render pipeline manager
  65638. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65639. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65640. */
  65641. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65642. }
  65643. /**
  65644. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65645. */
  65646. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65647. /**
  65648. * The component name helpfull to identify the component in the list of scene components.
  65649. */
  65650. readonly name: string;
  65651. /**
  65652. * The scene the component belongs to.
  65653. */
  65654. scene: Scene;
  65655. /**
  65656. * Creates a new instance of the component for the given scene
  65657. * @param scene Defines the scene to register the component in
  65658. */
  65659. constructor(scene: Scene);
  65660. /**
  65661. * Registers the component in a given scene
  65662. */
  65663. register(): void;
  65664. /**
  65665. * Rebuilds the elements related to this component in case of
  65666. * context lost for instance.
  65667. */
  65668. rebuild(): void;
  65669. /**
  65670. * Disposes the component and the associated ressources
  65671. */
  65672. dispose(): void;
  65673. private _gatherRenderTargets;
  65674. }
  65675. }
  65676. declare module BABYLON {
  65677. /**
  65678. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65679. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65680. */
  65681. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65682. private _scene;
  65683. private _camerasToBeAttached;
  65684. /**
  65685. * ID of the sharpen post process,
  65686. */
  65687. private readonly SharpenPostProcessId;
  65688. /**
  65689. * @ignore
  65690. * ID of the image processing post process;
  65691. */
  65692. readonly ImageProcessingPostProcessId: string;
  65693. /**
  65694. * @ignore
  65695. * ID of the Fast Approximate Anti-Aliasing post process;
  65696. */
  65697. readonly FxaaPostProcessId: string;
  65698. /**
  65699. * ID of the chromatic aberration post process,
  65700. */
  65701. private readonly ChromaticAberrationPostProcessId;
  65702. /**
  65703. * ID of the grain post process
  65704. */
  65705. private readonly GrainPostProcessId;
  65706. /**
  65707. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65708. */
  65709. sharpen: SharpenPostProcess;
  65710. private _sharpenEffect;
  65711. private bloom;
  65712. /**
  65713. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65714. */
  65715. depthOfField: DepthOfFieldEffect;
  65716. /**
  65717. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65718. */
  65719. fxaa: FxaaPostProcess;
  65720. /**
  65721. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65722. */
  65723. imageProcessing: ImageProcessingPostProcess;
  65724. /**
  65725. * Chromatic aberration post process which will shift rgb colors in the image
  65726. */
  65727. chromaticAberration: ChromaticAberrationPostProcess;
  65728. private _chromaticAberrationEffect;
  65729. /**
  65730. * Grain post process which add noise to the image
  65731. */
  65732. grain: GrainPostProcess;
  65733. private _grainEffect;
  65734. /**
  65735. * Glow post process which adds a glow to emissive areas of the image
  65736. */
  65737. private _glowLayer;
  65738. /**
  65739. * Animations which can be used to tweak settings over a period of time
  65740. */
  65741. animations: Animation[];
  65742. private _imageProcessingConfigurationObserver;
  65743. private _sharpenEnabled;
  65744. private _bloomEnabled;
  65745. private _depthOfFieldEnabled;
  65746. private _depthOfFieldBlurLevel;
  65747. private _fxaaEnabled;
  65748. private _imageProcessingEnabled;
  65749. private _defaultPipelineTextureType;
  65750. private _bloomScale;
  65751. private _chromaticAberrationEnabled;
  65752. private _grainEnabled;
  65753. private _buildAllowed;
  65754. /**
  65755. * Gets active scene
  65756. */
  65757. get scene(): Scene;
  65758. /**
  65759. * Enable or disable the sharpen process from the pipeline
  65760. */
  65761. set sharpenEnabled(enabled: boolean);
  65762. get sharpenEnabled(): boolean;
  65763. private _resizeObserver;
  65764. private _hardwareScaleLevel;
  65765. private _bloomKernel;
  65766. /**
  65767. * Specifies the size of the bloom blur kernel, relative to the final output size
  65768. */
  65769. get bloomKernel(): number;
  65770. set bloomKernel(value: number);
  65771. /**
  65772. * Specifies the weight of the bloom in the final rendering
  65773. */
  65774. private _bloomWeight;
  65775. /**
  65776. * Specifies the luma threshold for the area that will be blurred by the bloom
  65777. */
  65778. private _bloomThreshold;
  65779. private _hdr;
  65780. /**
  65781. * The strength of the bloom.
  65782. */
  65783. set bloomWeight(value: number);
  65784. get bloomWeight(): number;
  65785. /**
  65786. * The strength of the bloom.
  65787. */
  65788. set bloomThreshold(value: number);
  65789. get bloomThreshold(): number;
  65790. /**
  65791. * The scale of the bloom, lower value will provide better performance.
  65792. */
  65793. set bloomScale(value: number);
  65794. get bloomScale(): number;
  65795. /**
  65796. * Enable or disable the bloom from the pipeline
  65797. */
  65798. set bloomEnabled(enabled: boolean);
  65799. get bloomEnabled(): boolean;
  65800. private _rebuildBloom;
  65801. /**
  65802. * If the depth of field is enabled.
  65803. */
  65804. get depthOfFieldEnabled(): boolean;
  65805. set depthOfFieldEnabled(enabled: boolean);
  65806. /**
  65807. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65808. */
  65809. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65810. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65811. /**
  65812. * If the anti aliasing is enabled.
  65813. */
  65814. set fxaaEnabled(enabled: boolean);
  65815. get fxaaEnabled(): boolean;
  65816. private _samples;
  65817. /**
  65818. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65819. */
  65820. set samples(sampleCount: number);
  65821. get samples(): number;
  65822. /**
  65823. * If image processing is enabled.
  65824. */
  65825. set imageProcessingEnabled(enabled: boolean);
  65826. get imageProcessingEnabled(): boolean;
  65827. /**
  65828. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65829. */
  65830. set glowLayerEnabled(enabled: boolean);
  65831. get glowLayerEnabled(): boolean;
  65832. /**
  65833. * Gets the glow layer (or null if not defined)
  65834. */
  65835. get glowLayer(): Nullable<GlowLayer>;
  65836. /**
  65837. * Enable or disable the chromaticAberration process from the pipeline
  65838. */
  65839. set chromaticAberrationEnabled(enabled: boolean);
  65840. get chromaticAberrationEnabled(): boolean;
  65841. /**
  65842. * Enable or disable the grain process from the pipeline
  65843. */
  65844. set grainEnabled(enabled: boolean);
  65845. get grainEnabled(): boolean;
  65846. /**
  65847. * @constructor
  65848. * @param name - The rendering pipeline name (default: "")
  65849. * @param hdr - If high dynamic range textures should be used (default: true)
  65850. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65851. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65852. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65853. */
  65854. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65855. /**
  65856. * Get the class name
  65857. * @returns "DefaultRenderingPipeline"
  65858. */
  65859. getClassName(): string;
  65860. /**
  65861. * Force the compilation of the entire pipeline.
  65862. */
  65863. prepare(): void;
  65864. private _hasCleared;
  65865. private _prevPostProcess;
  65866. private _prevPrevPostProcess;
  65867. private _setAutoClearAndTextureSharing;
  65868. private _depthOfFieldSceneObserver;
  65869. private _buildPipeline;
  65870. private _disposePostProcesses;
  65871. /**
  65872. * Adds a camera to the pipeline
  65873. * @param camera the camera to be added
  65874. */
  65875. addCamera(camera: Camera): void;
  65876. /**
  65877. * Removes a camera from the pipeline
  65878. * @param camera the camera to remove
  65879. */
  65880. removeCamera(camera: Camera): void;
  65881. /**
  65882. * Dispose of the pipeline and stop all post processes
  65883. */
  65884. dispose(): void;
  65885. /**
  65886. * Serialize the rendering pipeline (Used when exporting)
  65887. * @returns the serialized object
  65888. */
  65889. serialize(): any;
  65890. /**
  65891. * Parse the serialized pipeline
  65892. * @param source Source pipeline.
  65893. * @param scene The scene to load the pipeline to.
  65894. * @param rootUrl The URL of the serialized pipeline.
  65895. * @returns An instantiated pipeline from the serialized object.
  65896. */
  65897. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65898. }
  65899. }
  65900. declare module BABYLON {
  65901. /** @hidden */
  65902. export var lensHighlightsPixelShader: {
  65903. name: string;
  65904. shader: string;
  65905. };
  65906. }
  65907. declare module BABYLON {
  65908. /** @hidden */
  65909. export var depthOfFieldPixelShader: {
  65910. name: string;
  65911. shader: string;
  65912. };
  65913. }
  65914. declare module BABYLON {
  65915. /**
  65916. * BABYLON.JS Chromatic Aberration GLSL Shader
  65917. * Author: Olivier Guyot
  65918. * Separates very slightly R, G and B colors on the edges of the screen
  65919. * Inspired by Francois Tarlier & Martins Upitis
  65920. */
  65921. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65922. /**
  65923. * @ignore
  65924. * The chromatic aberration PostProcess id in the pipeline
  65925. */
  65926. LensChromaticAberrationEffect: string;
  65927. /**
  65928. * @ignore
  65929. * The highlights enhancing PostProcess id in the pipeline
  65930. */
  65931. HighlightsEnhancingEffect: string;
  65932. /**
  65933. * @ignore
  65934. * The depth-of-field PostProcess id in the pipeline
  65935. */
  65936. LensDepthOfFieldEffect: string;
  65937. private _scene;
  65938. private _depthTexture;
  65939. private _grainTexture;
  65940. private _chromaticAberrationPostProcess;
  65941. private _highlightsPostProcess;
  65942. private _depthOfFieldPostProcess;
  65943. private _edgeBlur;
  65944. private _grainAmount;
  65945. private _chromaticAberration;
  65946. private _distortion;
  65947. private _highlightsGain;
  65948. private _highlightsThreshold;
  65949. private _dofDistance;
  65950. private _dofAperture;
  65951. private _dofDarken;
  65952. private _dofPentagon;
  65953. private _blurNoise;
  65954. /**
  65955. * @constructor
  65956. *
  65957. * Effect parameters are as follow:
  65958. * {
  65959. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65960. * edge_blur: number; // from 0 to x (1 for realism)
  65961. * distortion: number; // from 0 to x (1 for realism)
  65962. * grain_amount: number; // from 0 to 1
  65963. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65964. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65965. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65966. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65967. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65968. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65969. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65970. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65971. * }
  65972. * Note: if an effect parameter is unset, effect is disabled
  65973. *
  65974. * @param name The rendering pipeline name
  65975. * @param parameters - An object containing all parameters (see above)
  65976. * @param scene The scene linked to this pipeline
  65977. * @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)
  65978. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65979. */
  65980. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65981. /**
  65982. * Get the class name
  65983. * @returns "LensRenderingPipeline"
  65984. */
  65985. getClassName(): string;
  65986. /**
  65987. * Gets associated scene
  65988. */
  65989. get scene(): Scene;
  65990. /**
  65991. * Gets or sets the edge blur
  65992. */
  65993. get edgeBlur(): number;
  65994. set edgeBlur(value: number);
  65995. /**
  65996. * Gets or sets the grain amount
  65997. */
  65998. get grainAmount(): number;
  65999. set grainAmount(value: number);
  66000. /**
  66001. * Gets or sets the chromatic aberration amount
  66002. */
  66003. get chromaticAberration(): number;
  66004. set chromaticAberration(value: number);
  66005. /**
  66006. * Gets or sets the depth of field aperture
  66007. */
  66008. get dofAperture(): number;
  66009. set dofAperture(value: number);
  66010. /**
  66011. * Gets or sets the edge distortion
  66012. */
  66013. get edgeDistortion(): number;
  66014. set edgeDistortion(value: number);
  66015. /**
  66016. * Gets or sets the depth of field distortion
  66017. */
  66018. get dofDistortion(): number;
  66019. set dofDistortion(value: number);
  66020. /**
  66021. * Gets or sets the darken out of focus amount
  66022. */
  66023. get darkenOutOfFocus(): number;
  66024. set darkenOutOfFocus(value: number);
  66025. /**
  66026. * Gets or sets a boolean indicating if blur noise is enabled
  66027. */
  66028. get blurNoise(): boolean;
  66029. set blurNoise(value: boolean);
  66030. /**
  66031. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66032. */
  66033. get pentagonBokeh(): boolean;
  66034. set pentagonBokeh(value: boolean);
  66035. /**
  66036. * Gets or sets the highlight grain amount
  66037. */
  66038. get highlightsGain(): number;
  66039. set highlightsGain(value: number);
  66040. /**
  66041. * Gets or sets the highlight threshold
  66042. */
  66043. get highlightsThreshold(): number;
  66044. set highlightsThreshold(value: number);
  66045. /**
  66046. * Sets the amount of blur at the edges
  66047. * @param amount blur amount
  66048. */
  66049. setEdgeBlur(amount: number): void;
  66050. /**
  66051. * Sets edge blur to 0
  66052. */
  66053. disableEdgeBlur(): void;
  66054. /**
  66055. * Sets the amout of grain
  66056. * @param amount Amount of grain
  66057. */
  66058. setGrainAmount(amount: number): void;
  66059. /**
  66060. * Set grain amount to 0
  66061. */
  66062. disableGrain(): void;
  66063. /**
  66064. * Sets the chromatic aberration amount
  66065. * @param amount amount of chromatic aberration
  66066. */
  66067. setChromaticAberration(amount: number): void;
  66068. /**
  66069. * Sets chromatic aberration amount to 0
  66070. */
  66071. disableChromaticAberration(): void;
  66072. /**
  66073. * Sets the EdgeDistortion amount
  66074. * @param amount amount of EdgeDistortion
  66075. */
  66076. setEdgeDistortion(amount: number): void;
  66077. /**
  66078. * Sets edge distortion to 0
  66079. */
  66080. disableEdgeDistortion(): void;
  66081. /**
  66082. * Sets the FocusDistance amount
  66083. * @param amount amount of FocusDistance
  66084. */
  66085. setFocusDistance(amount: number): void;
  66086. /**
  66087. * Disables depth of field
  66088. */
  66089. disableDepthOfField(): void;
  66090. /**
  66091. * Sets the Aperture amount
  66092. * @param amount amount of Aperture
  66093. */
  66094. setAperture(amount: number): void;
  66095. /**
  66096. * Sets the DarkenOutOfFocus amount
  66097. * @param amount amount of DarkenOutOfFocus
  66098. */
  66099. setDarkenOutOfFocus(amount: number): void;
  66100. private _pentagonBokehIsEnabled;
  66101. /**
  66102. * Creates a pentagon bokeh effect
  66103. */
  66104. enablePentagonBokeh(): void;
  66105. /**
  66106. * Disables the pentagon bokeh effect
  66107. */
  66108. disablePentagonBokeh(): void;
  66109. /**
  66110. * Enables noise blur
  66111. */
  66112. enableNoiseBlur(): void;
  66113. /**
  66114. * Disables noise blur
  66115. */
  66116. disableNoiseBlur(): void;
  66117. /**
  66118. * Sets the HighlightsGain amount
  66119. * @param amount amount of HighlightsGain
  66120. */
  66121. setHighlightsGain(amount: number): void;
  66122. /**
  66123. * Sets the HighlightsThreshold amount
  66124. * @param amount amount of HighlightsThreshold
  66125. */
  66126. setHighlightsThreshold(amount: number): void;
  66127. /**
  66128. * Disables highlights
  66129. */
  66130. disableHighlights(): void;
  66131. /**
  66132. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66133. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66134. */
  66135. dispose(disableDepthRender?: boolean): void;
  66136. private _createChromaticAberrationPostProcess;
  66137. private _createHighlightsPostProcess;
  66138. private _createDepthOfFieldPostProcess;
  66139. private _createGrainTexture;
  66140. }
  66141. }
  66142. declare module BABYLON {
  66143. /** @hidden */
  66144. export var ssao2PixelShader: {
  66145. name: string;
  66146. shader: string;
  66147. };
  66148. }
  66149. declare module BABYLON {
  66150. /** @hidden */
  66151. export var ssaoCombinePixelShader: {
  66152. name: string;
  66153. shader: string;
  66154. };
  66155. }
  66156. declare module BABYLON {
  66157. /**
  66158. * Render pipeline to produce ssao effect
  66159. */
  66160. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66161. /**
  66162. * @ignore
  66163. * The PassPostProcess id in the pipeline that contains the original scene color
  66164. */
  66165. SSAOOriginalSceneColorEffect: string;
  66166. /**
  66167. * @ignore
  66168. * The SSAO PostProcess id in the pipeline
  66169. */
  66170. SSAORenderEffect: string;
  66171. /**
  66172. * @ignore
  66173. * The horizontal blur PostProcess id in the pipeline
  66174. */
  66175. SSAOBlurHRenderEffect: string;
  66176. /**
  66177. * @ignore
  66178. * The vertical blur PostProcess id in the pipeline
  66179. */
  66180. SSAOBlurVRenderEffect: string;
  66181. /**
  66182. * @ignore
  66183. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66184. */
  66185. SSAOCombineRenderEffect: string;
  66186. /**
  66187. * The output strength of the SSAO post-process. Default value is 1.0.
  66188. */
  66189. totalStrength: number;
  66190. /**
  66191. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66192. */
  66193. maxZ: number;
  66194. /**
  66195. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66196. */
  66197. minZAspect: number;
  66198. private _samples;
  66199. /**
  66200. * Number of samples used for the SSAO calculations. Default value is 8
  66201. */
  66202. set samples(n: number);
  66203. get samples(): number;
  66204. private _textureSamples;
  66205. /**
  66206. * Number of samples to use for antialiasing
  66207. */
  66208. set textureSamples(n: number);
  66209. get textureSamples(): number;
  66210. /**
  66211. * Ratio object used for SSAO ratio and blur ratio
  66212. */
  66213. private _ratio;
  66214. /**
  66215. * Dynamically generated sphere sampler.
  66216. */
  66217. private _sampleSphere;
  66218. /**
  66219. * Blur filter offsets
  66220. */
  66221. private _samplerOffsets;
  66222. private _expensiveBlur;
  66223. /**
  66224. * If bilateral blur should be used
  66225. */
  66226. set expensiveBlur(b: boolean);
  66227. get expensiveBlur(): boolean;
  66228. /**
  66229. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66230. */
  66231. radius: number;
  66232. /**
  66233. * The base color of the SSAO post-process
  66234. * The final result is "base + ssao" between [0, 1]
  66235. */
  66236. base: number;
  66237. /**
  66238. * Support test.
  66239. */
  66240. static get IsSupported(): boolean;
  66241. private _scene;
  66242. private _depthTexture;
  66243. private _normalTexture;
  66244. private _randomTexture;
  66245. private _originalColorPostProcess;
  66246. private _ssaoPostProcess;
  66247. private _blurHPostProcess;
  66248. private _blurVPostProcess;
  66249. private _ssaoCombinePostProcess;
  66250. /**
  66251. * Gets active scene
  66252. */
  66253. get scene(): Scene;
  66254. /**
  66255. * @constructor
  66256. * @param name The rendering pipeline name
  66257. * @param scene The scene linked to this pipeline
  66258. * @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 }
  66259. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66260. */
  66261. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66262. /**
  66263. * Get the class name
  66264. * @returns "SSAO2RenderingPipeline"
  66265. */
  66266. getClassName(): string;
  66267. /**
  66268. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66269. */
  66270. dispose(disableGeometryBufferRenderer?: boolean): void;
  66271. private _createBlurPostProcess;
  66272. /** @hidden */
  66273. _rebuild(): void;
  66274. private _bits;
  66275. private _radicalInverse_VdC;
  66276. private _hammersley;
  66277. private _hemisphereSample_uniform;
  66278. private _generateHemisphere;
  66279. private _createSSAOPostProcess;
  66280. private _createSSAOCombinePostProcess;
  66281. private _createRandomTexture;
  66282. /**
  66283. * Serialize the rendering pipeline (Used when exporting)
  66284. * @returns the serialized object
  66285. */
  66286. serialize(): any;
  66287. /**
  66288. * Parse the serialized pipeline
  66289. * @param source Source pipeline.
  66290. * @param scene The scene to load the pipeline to.
  66291. * @param rootUrl The URL of the serialized pipeline.
  66292. * @returns An instantiated pipeline from the serialized object.
  66293. */
  66294. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66295. }
  66296. }
  66297. declare module BABYLON {
  66298. /** @hidden */
  66299. export var ssaoPixelShader: {
  66300. name: string;
  66301. shader: string;
  66302. };
  66303. }
  66304. declare module BABYLON {
  66305. /**
  66306. * Render pipeline to produce ssao effect
  66307. */
  66308. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66309. /**
  66310. * @ignore
  66311. * The PassPostProcess id in the pipeline that contains the original scene color
  66312. */
  66313. SSAOOriginalSceneColorEffect: string;
  66314. /**
  66315. * @ignore
  66316. * The SSAO PostProcess id in the pipeline
  66317. */
  66318. SSAORenderEffect: string;
  66319. /**
  66320. * @ignore
  66321. * The horizontal blur PostProcess id in the pipeline
  66322. */
  66323. SSAOBlurHRenderEffect: string;
  66324. /**
  66325. * @ignore
  66326. * The vertical blur PostProcess id in the pipeline
  66327. */
  66328. SSAOBlurVRenderEffect: string;
  66329. /**
  66330. * @ignore
  66331. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66332. */
  66333. SSAOCombineRenderEffect: string;
  66334. /**
  66335. * The output strength of the SSAO post-process. Default value is 1.0.
  66336. */
  66337. totalStrength: number;
  66338. /**
  66339. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66340. */
  66341. radius: number;
  66342. /**
  66343. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66344. * Must not be equal to fallOff and superior to fallOff.
  66345. * Default value is 0.0075
  66346. */
  66347. area: number;
  66348. /**
  66349. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66350. * Must not be equal to area and inferior to area.
  66351. * Default value is 0.000001
  66352. */
  66353. fallOff: number;
  66354. /**
  66355. * The base color of the SSAO post-process
  66356. * The final result is "base + ssao" between [0, 1]
  66357. */
  66358. base: number;
  66359. private _scene;
  66360. private _depthTexture;
  66361. private _randomTexture;
  66362. private _originalColorPostProcess;
  66363. private _ssaoPostProcess;
  66364. private _blurHPostProcess;
  66365. private _blurVPostProcess;
  66366. private _ssaoCombinePostProcess;
  66367. private _firstUpdate;
  66368. /**
  66369. * Gets active scene
  66370. */
  66371. get scene(): Scene;
  66372. /**
  66373. * @constructor
  66374. * @param name - The rendering pipeline name
  66375. * @param scene - The scene linked to this pipeline
  66376. * @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 }
  66377. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66378. */
  66379. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66380. /**
  66381. * Get the class name
  66382. * @returns "SSAORenderingPipeline"
  66383. */
  66384. getClassName(): string;
  66385. /**
  66386. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66387. */
  66388. dispose(disableDepthRender?: boolean): void;
  66389. private _createBlurPostProcess;
  66390. /** @hidden */
  66391. _rebuild(): void;
  66392. private _createSSAOPostProcess;
  66393. private _createSSAOCombinePostProcess;
  66394. private _createRandomTexture;
  66395. }
  66396. }
  66397. declare module BABYLON {
  66398. /** @hidden */
  66399. export var screenSpaceReflectionPixelShader: {
  66400. name: string;
  66401. shader: string;
  66402. };
  66403. }
  66404. declare module BABYLON {
  66405. /**
  66406. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66407. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66408. */
  66409. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66410. /**
  66411. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66412. */
  66413. threshold: number;
  66414. /**
  66415. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66416. */
  66417. strength: number;
  66418. /**
  66419. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66420. */
  66421. reflectionSpecularFalloffExponent: number;
  66422. /**
  66423. * 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]
  66424. */
  66425. step: number;
  66426. /**
  66427. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66428. */
  66429. roughnessFactor: number;
  66430. private _geometryBufferRenderer;
  66431. private _enableSmoothReflections;
  66432. private _reflectionSamples;
  66433. private _smoothSteps;
  66434. /**
  66435. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66436. * @param name The name of the effect.
  66437. * @param scene The scene containing the objects to calculate reflections.
  66438. * @param options The required width/height ratio to downsize to before computing the render pass.
  66439. * @param camera The camera to apply the render pass to.
  66440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66441. * @param engine The engine which the post process will be applied. (default: current engine)
  66442. * @param reusable If the post process can be reused on the same frame. (default: false)
  66443. * @param textureType Type of textures used when performing the post process. (default: 0)
  66444. * @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)
  66445. */
  66446. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66447. /**
  66448. * Gets wether or not smoothing reflections is enabled.
  66449. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66450. */
  66451. get enableSmoothReflections(): boolean;
  66452. /**
  66453. * Sets wether or not smoothing reflections is enabled.
  66454. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66455. */
  66456. set enableSmoothReflections(enabled: boolean);
  66457. /**
  66458. * Gets the number of samples taken while computing reflections. More samples count is high,
  66459. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66460. */
  66461. get reflectionSamples(): number;
  66462. /**
  66463. * Sets the number of samples taken while computing reflections. More samples count is high,
  66464. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66465. */
  66466. set reflectionSamples(samples: number);
  66467. /**
  66468. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66469. * more the post-process will require GPU power and can generate a drop in FPS.
  66470. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66471. */
  66472. get smoothSteps(): number;
  66473. set smoothSteps(steps: number);
  66474. private _updateEffectDefines;
  66475. }
  66476. }
  66477. declare module BABYLON {
  66478. /** @hidden */
  66479. export var standardPixelShader: {
  66480. name: string;
  66481. shader: string;
  66482. };
  66483. }
  66484. declare module BABYLON {
  66485. /**
  66486. * Standard rendering pipeline
  66487. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66488. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66489. */
  66490. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66491. /**
  66492. * Public members
  66493. */
  66494. /**
  66495. * Post-process which contains the original scene color before the pipeline applies all the effects
  66496. */
  66497. originalPostProcess: Nullable<PostProcess>;
  66498. /**
  66499. * Post-process used to down scale an image x4
  66500. */
  66501. downSampleX4PostProcess: Nullable<PostProcess>;
  66502. /**
  66503. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66504. */
  66505. brightPassPostProcess: Nullable<PostProcess>;
  66506. /**
  66507. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66508. */
  66509. blurHPostProcesses: PostProcess[];
  66510. /**
  66511. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66512. */
  66513. blurVPostProcesses: PostProcess[];
  66514. /**
  66515. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66516. */
  66517. textureAdderPostProcess: Nullable<PostProcess>;
  66518. /**
  66519. * Post-process used to create volumetric lighting effect
  66520. */
  66521. volumetricLightPostProcess: Nullable<PostProcess>;
  66522. /**
  66523. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66524. */
  66525. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66526. /**
  66527. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66528. */
  66529. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66530. /**
  66531. * Post-process used to merge the volumetric light effect and the real scene color
  66532. */
  66533. volumetricLightMergePostProces: Nullable<PostProcess>;
  66534. /**
  66535. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66536. */
  66537. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66538. /**
  66539. * Base post-process used to calculate the average luminance of the final image for HDR
  66540. */
  66541. luminancePostProcess: Nullable<PostProcess>;
  66542. /**
  66543. * Post-processes used to create down sample post-processes in order to get
  66544. * the average luminance of the final image for HDR
  66545. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66546. */
  66547. luminanceDownSamplePostProcesses: PostProcess[];
  66548. /**
  66549. * Post-process used to create a HDR effect (light adaptation)
  66550. */
  66551. hdrPostProcess: Nullable<PostProcess>;
  66552. /**
  66553. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66554. */
  66555. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66556. /**
  66557. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66558. */
  66559. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66560. /**
  66561. * Post-process used to merge the final HDR post-process and the real scene color
  66562. */
  66563. hdrFinalPostProcess: Nullable<PostProcess>;
  66564. /**
  66565. * Post-process used to create a lens flare effect
  66566. */
  66567. lensFlarePostProcess: Nullable<PostProcess>;
  66568. /**
  66569. * Post-process that merges the result of the lens flare post-process and the real scene color
  66570. */
  66571. lensFlareComposePostProcess: Nullable<PostProcess>;
  66572. /**
  66573. * Post-process used to create a motion blur effect
  66574. */
  66575. motionBlurPostProcess: Nullable<PostProcess>;
  66576. /**
  66577. * Post-process used to create a depth of field effect
  66578. */
  66579. depthOfFieldPostProcess: Nullable<PostProcess>;
  66580. /**
  66581. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66582. */
  66583. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66584. /**
  66585. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66586. */
  66587. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66588. /**
  66589. * Represents the brightness threshold in order to configure the illuminated surfaces
  66590. */
  66591. brightThreshold: number;
  66592. /**
  66593. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66594. */
  66595. blurWidth: number;
  66596. /**
  66597. * Sets if the blur for highlighted surfaces must be only horizontal
  66598. */
  66599. horizontalBlur: boolean;
  66600. /**
  66601. * Gets the overall exposure used by the pipeline
  66602. */
  66603. get exposure(): number;
  66604. /**
  66605. * Sets the overall exposure used by the pipeline
  66606. */
  66607. set exposure(value: number);
  66608. /**
  66609. * Texture used typically to simulate "dirty" on camera lens
  66610. */
  66611. lensTexture: Nullable<Texture>;
  66612. /**
  66613. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66614. */
  66615. volumetricLightCoefficient: number;
  66616. /**
  66617. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66618. */
  66619. volumetricLightPower: number;
  66620. /**
  66621. * Used the set the blur intensity to smooth the volumetric lights
  66622. */
  66623. volumetricLightBlurScale: number;
  66624. /**
  66625. * Light (spot or directional) used to generate the volumetric lights rays
  66626. * The source light must have a shadow generate so the pipeline can get its
  66627. * depth map
  66628. */
  66629. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66630. /**
  66631. * For eye adaptation, represents the minimum luminance the eye can see
  66632. */
  66633. hdrMinimumLuminance: number;
  66634. /**
  66635. * For eye adaptation, represents the decrease luminance speed
  66636. */
  66637. hdrDecreaseRate: number;
  66638. /**
  66639. * For eye adaptation, represents the increase luminance speed
  66640. */
  66641. hdrIncreaseRate: number;
  66642. /**
  66643. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66644. */
  66645. get hdrAutoExposure(): boolean;
  66646. /**
  66647. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66648. */
  66649. set hdrAutoExposure(value: boolean);
  66650. /**
  66651. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66652. */
  66653. lensColorTexture: Nullable<Texture>;
  66654. /**
  66655. * The overall strengh for the lens flare effect
  66656. */
  66657. lensFlareStrength: number;
  66658. /**
  66659. * Dispersion coefficient for lens flare ghosts
  66660. */
  66661. lensFlareGhostDispersal: number;
  66662. /**
  66663. * Main lens flare halo width
  66664. */
  66665. lensFlareHaloWidth: number;
  66666. /**
  66667. * Based on the lens distortion effect, defines how much the lens flare result
  66668. * is distorted
  66669. */
  66670. lensFlareDistortionStrength: number;
  66671. /**
  66672. * Configures the blur intensity used for for lens flare (halo)
  66673. */
  66674. lensFlareBlurWidth: number;
  66675. /**
  66676. * Lens star texture must be used to simulate rays on the flares and is available
  66677. * in the documentation
  66678. */
  66679. lensStarTexture: Nullable<Texture>;
  66680. /**
  66681. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66682. * flare effect by taking account of the dirt texture
  66683. */
  66684. lensFlareDirtTexture: Nullable<Texture>;
  66685. /**
  66686. * Represents the focal length for the depth of field effect
  66687. */
  66688. depthOfFieldDistance: number;
  66689. /**
  66690. * Represents the blur intensity for the blurred part of the depth of field effect
  66691. */
  66692. depthOfFieldBlurWidth: number;
  66693. /**
  66694. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66695. */
  66696. get motionStrength(): number;
  66697. /**
  66698. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66699. */
  66700. set motionStrength(strength: number);
  66701. /**
  66702. * Gets wether or not the motion blur post-process is object based or screen based.
  66703. */
  66704. get objectBasedMotionBlur(): boolean;
  66705. /**
  66706. * Sets wether or not the motion blur post-process should be object based or screen based
  66707. */
  66708. set objectBasedMotionBlur(value: boolean);
  66709. /**
  66710. * List of animations for the pipeline (IAnimatable implementation)
  66711. */
  66712. animations: Animation[];
  66713. /**
  66714. * Private members
  66715. */
  66716. private _scene;
  66717. private _currentDepthOfFieldSource;
  66718. private _basePostProcess;
  66719. private _fixedExposure;
  66720. private _currentExposure;
  66721. private _hdrAutoExposure;
  66722. private _hdrCurrentLuminance;
  66723. private _motionStrength;
  66724. private _isObjectBasedMotionBlur;
  66725. private _floatTextureType;
  66726. private _camerasToBeAttached;
  66727. private _ratio;
  66728. private _bloomEnabled;
  66729. private _depthOfFieldEnabled;
  66730. private _vlsEnabled;
  66731. private _lensFlareEnabled;
  66732. private _hdrEnabled;
  66733. private _motionBlurEnabled;
  66734. private _fxaaEnabled;
  66735. private _screenSpaceReflectionsEnabled;
  66736. private _motionBlurSamples;
  66737. private _volumetricLightStepsCount;
  66738. private _samples;
  66739. /**
  66740. * @ignore
  66741. * Specifies if the bloom pipeline is enabled
  66742. */
  66743. get BloomEnabled(): boolean;
  66744. set BloomEnabled(enabled: boolean);
  66745. /**
  66746. * @ignore
  66747. * Specifies if the depth of field pipeline is enabed
  66748. */
  66749. get DepthOfFieldEnabled(): boolean;
  66750. set DepthOfFieldEnabled(enabled: boolean);
  66751. /**
  66752. * @ignore
  66753. * Specifies if the lens flare pipeline is enabed
  66754. */
  66755. get LensFlareEnabled(): boolean;
  66756. set LensFlareEnabled(enabled: boolean);
  66757. /**
  66758. * @ignore
  66759. * Specifies if the HDR pipeline is enabled
  66760. */
  66761. get HDREnabled(): boolean;
  66762. set HDREnabled(enabled: boolean);
  66763. /**
  66764. * @ignore
  66765. * Specifies if the volumetric lights scattering effect is enabled
  66766. */
  66767. get VLSEnabled(): boolean;
  66768. set VLSEnabled(enabled: boolean);
  66769. /**
  66770. * @ignore
  66771. * Specifies if the motion blur effect is enabled
  66772. */
  66773. get MotionBlurEnabled(): boolean;
  66774. set MotionBlurEnabled(enabled: boolean);
  66775. /**
  66776. * Specifies if anti-aliasing is enabled
  66777. */
  66778. get fxaaEnabled(): boolean;
  66779. set fxaaEnabled(enabled: boolean);
  66780. /**
  66781. * Specifies if screen space reflections are enabled.
  66782. */
  66783. get screenSpaceReflectionsEnabled(): boolean;
  66784. set screenSpaceReflectionsEnabled(enabled: boolean);
  66785. /**
  66786. * Specifies the number of steps used to calculate the volumetric lights
  66787. * Typically in interval [50, 200]
  66788. */
  66789. get volumetricLightStepsCount(): number;
  66790. set volumetricLightStepsCount(count: number);
  66791. /**
  66792. * Specifies the number of samples used for the motion blur effect
  66793. * Typically in interval [16, 64]
  66794. */
  66795. get motionBlurSamples(): number;
  66796. set motionBlurSamples(samples: number);
  66797. /**
  66798. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66799. */
  66800. get samples(): number;
  66801. set samples(sampleCount: number);
  66802. /**
  66803. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66804. * @constructor
  66805. * @param name The rendering pipeline name
  66806. * @param scene The scene linked to this pipeline
  66807. * @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)
  66808. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66809. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66810. */
  66811. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66812. private _buildPipeline;
  66813. private _createDownSampleX4PostProcess;
  66814. private _createBrightPassPostProcess;
  66815. private _createBlurPostProcesses;
  66816. private _createTextureAdderPostProcess;
  66817. private _createVolumetricLightPostProcess;
  66818. private _createLuminancePostProcesses;
  66819. private _createHdrPostProcess;
  66820. private _createLensFlarePostProcess;
  66821. private _createDepthOfFieldPostProcess;
  66822. private _createMotionBlurPostProcess;
  66823. private _getDepthTexture;
  66824. private _disposePostProcesses;
  66825. /**
  66826. * Dispose of the pipeline and stop all post processes
  66827. */
  66828. dispose(): void;
  66829. /**
  66830. * Serialize the rendering pipeline (Used when exporting)
  66831. * @returns the serialized object
  66832. */
  66833. serialize(): any;
  66834. /**
  66835. * Parse the serialized pipeline
  66836. * @param source Source pipeline.
  66837. * @param scene The scene to load the pipeline to.
  66838. * @param rootUrl The URL of the serialized pipeline.
  66839. * @returns An instantiated pipeline from the serialized object.
  66840. */
  66841. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66842. /**
  66843. * Luminance steps
  66844. */
  66845. static LuminanceSteps: number;
  66846. }
  66847. }
  66848. declare module BABYLON {
  66849. /** @hidden */
  66850. export var tonemapPixelShader: {
  66851. name: string;
  66852. shader: string;
  66853. };
  66854. }
  66855. declare module BABYLON {
  66856. /** Defines operator used for tonemapping */
  66857. export enum TonemappingOperator {
  66858. /** Hable */
  66859. Hable = 0,
  66860. /** Reinhard */
  66861. Reinhard = 1,
  66862. /** HejiDawson */
  66863. HejiDawson = 2,
  66864. /** Photographic */
  66865. Photographic = 3
  66866. }
  66867. /**
  66868. * Defines a post process to apply tone mapping
  66869. */
  66870. export class TonemapPostProcess extends PostProcess {
  66871. private _operator;
  66872. /** Defines the required exposure adjustement */
  66873. exposureAdjustment: number;
  66874. /**
  66875. * Creates a new TonemapPostProcess
  66876. * @param name defines the name of the postprocess
  66877. * @param _operator defines the operator to use
  66878. * @param exposureAdjustment defines the required exposure adjustement
  66879. * @param camera defines the camera to use (can be null)
  66880. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66881. * @param engine defines the hosting engine (can be ignore if camera is set)
  66882. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66883. */
  66884. constructor(name: string, _operator: TonemappingOperator,
  66885. /** Defines the required exposure adjustement */
  66886. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66887. }
  66888. }
  66889. declare module BABYLON {
  66890. /** @hidden */
  66891. export var volumetricLightScatteringPixelShader: {
  66892. name: string;
  66893. shader: string;
  66894. };
  66895. }
  66896. declare module BABYLON {
  66897. /** @hidden */
  66898. export var volumetricLightScatteringPassVertexShader: {
  66899. name: string;
  66900. shader: string;
  66901. };
  66902. }
  66903. declare module BABYLON {
  66904. /** @hidden */
  66905. export var volumetricLightScatteringPassPixelShader: {
  66906. name: string;
  66907. shader: string;
  66908. };
  66909. }
  66910. declare module BABYLON {
  66911. /**
  66912. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66913. */
  66914. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66915. private _volumetricLightScatteringPass;
  66916. private _volumetricLightScatteringRTT;
  66917. private _viewPort;
  66918. private _screenCoordinates;
  66919. private _cachedDefines;
  66920. /**
  66921. * If not undefined, the mesh position is computed from the attached node position
  66922. */
  66923. attachedNode: {
  66924. position: Vector3;
  66925. };
  66926. /**
  66927. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66928. */
  66929. customMeshPosition: Vector3;
  66930. /**
  66931. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66932. */
  66933. useCustomMeshPosition: boolean;
  66934. /**
  66935. * If the post-process should inverse the light scattering direction
  66936. */
  66937. invert: boolean;
  66938. /**
  66939. * The internal mesh used by the post-process
  66940. */
  66941. mesh: Mesh;
  66942. /**
  66943. * @hidden
  66944. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66945. */
  66946. get useDiffuseColor(): boolean;
  66947. set useDiffuseColor(useDiffuseColor: boolean);
  66948. /**
  66949. * Array containing the excluded meshes not rendered in the internal pass
  66950. */
  66951. excludedMeshes: AbstractMesh[];
  66952. /**
  66953. * Controls the overall intensity of the post-process
  66954. */
  66955. exposure: number;
  66956. /**
  66957. * Dissipates each sample's contribution in range [0, 1]
  66958. */
  66959. decay: number;
  66960. /**
  66961. * Controls the overall intensity of each sample
  66962. */
  66963. weight: number;
  66964. /**
  66965. * Controls the density of each sample
  66966. */
  66967. density: number;
  66968. /**
  66969. * @constructor
  66970. * @param name The post-process name
  66971. * @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)
  66972. * @param camera The camera that the post-process will be attached to
  66973. * @param mesh The mesh used to create the light scattering
  66974. * @param samples The post-process quality, default 100
  66975. * @param samplingModeThe post-process filtering mode
  66976. * @param engine The babylon engine
  66977. * @param reusable If the post-process is reusable
  66978. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66979. */
  66980. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66981. /**
  66982. * Returns the string "VolumetricLightScatteringPostProcess"
  66983. * @returns "VolumetricLightScatteringPostProcess"
  66984. */
  66985. getClassName(): string;
  66986. private _isReady;
  66987. /**
  66988. * Sets the new light position for light scattering effect
  66989. * @param position The new custom light position
  66990. */
  66991. setCustomMeshPosition(position: Vector3): void;
  66992. /**
  66993. * Returns the light position for light scattering effect
  66994. * @return Vector3 The custom light position
  66995. */
  66996. getCustomMeshPosition(): Vector3;
  66997. /**
  66998. * Disposes the internal assets and detaches the post-process from the camera
  66999. */
  67000. dispose(camera: Camera): void;
  67001. /**
  67002. * Returns the render target texture used by the post-process
  67003. * @return the render target texture used by the post-process
  67004. */
  67005. getPass(): RenderTargetTexture;
  67006. private _meshExcluded;
  67007. private _createPass;
  67008. private _updateMeshScreenCoordinates;
  67009. /**
  67010. * Creates a default mesh for the Volumeric Light Scattering post-process
  67011. * @param name The mesh name
  67012. * @param scene The scene where to create the mesh
  67013. * @return the default mesh
  67014. */
  67015. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67016. }
  67017. }
  67018. declare module BABYLON {
  67019. interface Scene {
  67020. /** @hidden (Backing field) */
  67021. _boundingBoxRenderer: BoundingBoxRenderer;
  67022. /** @hidden (Backing field) */
  67023. _forceShowBoundingBoxes: boolean;
  67024. /**
  67025. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67026. */
  67027. forceShowBoundingBoxes: boolean;
  67028. /**
  67029. * Gets the bounding box renderer associated with the scene
  67030. * @returns a BoundingBoxRenderer
  67031. */
  67032. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67033. }
  67034. interface AbstractMesh {
  67035. /** @hidden (Backing field) */
  67036. _showBoundingBox: boolean;
  67037. /**
  67038. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67039. */
  67040. showBoundingBox: boolean;
  67041. }
  67042. /**
  67043. * Component responsible of rendering the bounding box of the meshes in a scene.
  67044. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67045. */
  67046. export class BoundingBoxRenderer implements ISceneComponent {
  67047. /**
  67048. * The component name helpfull to identify the component in the list of scene components.
  67049. */
  67050. readonly name: string;
  67051. /**
  67052. * The scene the component belongs to.
  67053. */
  67054. scene: Scene;
  67055. /**
  67056. * Color of the bounding box lines placed in front of an object
  67057. */
  67058. frontColor: Color3;
  67059. /**
  67060. * Color of the bounding box lines placed behind an object
  67061. */
  67062. backColor: Color3;
  67063. /**
  67064. * Defines if the renderer should show the back lines or not
  67065. */
  67066. showBackLines: boolean;
  67067. /**
  67068. * @hidden
  67069. */
  67070. renderList: SmartArray<BoundingBox>;
  67071. private _colorShader;
  67072. private _vertexBuffers;
  67073. private _indexBuffer;
  67074. private _fillIndexBuffer;
  67075. private _fillIndexData;
  67076. /**
  67077. * Instantiates a new bounding box renderer in a scene.
  67078. * @param scene the scene the renderer renders in
  67079. */
  67080. constructor(scene: Scene);
  67081. /**
  67082. * Registers the component in a given scene
  67083. */
  67084. register(): void;
  67085. private _evaluateSubMesh;
  67086. private _activeMesh;
  67087. private _prepareRessources;
  67088. private _createIndexBuffer;
  67089. /**
  67090. * Rebuilds the elements related to this component in case of
  67091. * context lost for instance.
  67092. */
  67093. rebuild(): void;
  67094. /**
  67095. * @hidden
  67096. */
  67097. reset(): void;
  67098. /**
  67099. * Render the bounding boxes of a specific rendering group
  67100. * @param renderingGroupId defines the rendering group to render
  67101. */
  67102. render(renderingGroupId: number): void;
  67103. /**
  67104. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67105. * @param mesh Define the mesh to render the occlusion bounding box for
  67106. */
  67107. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67108. /**
  67109. * Dispose and release the resources attached to this renderer.
  67110. */
  67111. dispose(): void;
  67112. }
  67113. }
  67114. declare module BABYLON {
  67115. interface Scene {
  67116. /** @hidden (Backing field) */
  67117. _depthRenderer: {
  67118. [id: string]: DepthRenderer;
  67119. };
  67120. /**
  67121. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67122. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67123. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67124. * @returns the created depth renderer
  67125. */
  67126. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67127. /**
  67128. * Disables a depth renderer for a given camera
  67129. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67130. */
  67131. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67132. }
  67133. /**
  67134. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67135. * in several rendering techniques.
  67136. */
  67137. export class DepthRendererSceneComponent implements ISceneComponent {
  67138. /**
  67139. * The component name helpfull to identify the component in the list of scene components.
  67140. */
  67141. readonly name: string;
  67142. /**
  67143. * The scene the component belongs to.
  67144. */
  67145. scene: Scene;
  67146. /**
  67147. * Creates a new instance of the component for the given scene
  67148. * @param scene Defines the scene to register the component in
  67149. */
  67150. constructor(scene: Scene);
  67151. /**
  67152. * Registers the component in a given scene
  67153. */
  67154. register(): void;
  67155. /**
  67156. * Rebuilds the elements related to this component in case of
  67157. * context lost for instance.
  67158. */
  67159. rebuild(): void;
  67160. /**
  67161. * Disposes the component and the associated ressources
  67162. */
  67163. dispose(): void;
  67164. private _gatherRenderTargets;
  67165. private _gatherActiveCameraRenderTargets;
  67166. }
  67167. }
  67168. declare module BABYLON {
  67169. /** @hidden */
  67170. export var outlinePixelShader: {
  67171. name: string;
  67172. shader: string;
  67173. };
  67174. }
  67175. declare module BABYLON {
  67176. /** @hidden */
  67177. export var outlineVertexShader: {
  67178. name: string;
  67179. shader: string;
  67180. };
  67181. }
  67182. declare module BABYLON {
  67183. interface Scene {
  67184. /** @hidden */
  67185. _outlineRenderer: OutlineRenderer;
  67186. /**
  67187. * Gets the outline renderer associated with the scene
  67188. * @returns a OutlineRenderer
  67189. */
  67190. getOutlineRenderer(): OutlineRenderer;
  67191. }
  67192. interface AbstractMesh {
  67193. /** @hidden (Backing field) */
  67194. _renderOutline: boolean;
  67195. /**
  67196. * Gets or sets a boolean indicating if the outline must be rendered as well
  67197. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67198. */
  67199. renderOutline: boolean;
  67200. /** @hidden (Backing field) */
  67201. _renderOverlay: boolean;
  67202. /**
  67203. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67204. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67205. */
  67206. renderOverlay: boolean;
  67207. }
  67208. /**
  67209. * This class is responsible to draw bothe outline/overlay of meshes.
  67210. * It should not be used directly but through the available method on mesh.
  67211. */
  67212. export class OutlineRenderer implements ISceneComponent {
  67213. /**
  67214. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67215. */
  67216. private static _StencilReference;
  67217. /**
  67218. * The name of the component. Each component must have a unique name.
  67219. */
  67220. name: string;
  67221. /**
  67222. * The scene the component belongs to.
  67223. */
  67224. scene: Scene;
  67225. /**
  67226. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67227. */
  67228. zOffset: number;
  67229. private _engine;
  67230. private _effect;
  67231. private _cachedDefines;
  67232. private _savedDepthWrite;
  67233. /**
  67234. * Instantiates a new outline renderer. (There could be only one per scene).
  67235. * @param scene Defines the scene it belongs to
  67236. */
  67237. constructor(scene: Scene);
  67238. /**
  67239. * Register the component to one instance of a scene.
  67240. */
  67241. register(): void;
  67242. /**
  67243. * Rebuilds the elements related to this component in case of
  67244. * context lost for instance.
  67245. */
  67246. rebuild(): void;
  67247. /**
  67248. * Disposes the component and the associated ressources.
  67249. */
  67250. dispose(): void;
  67251. /**
  67252. * Renders the outline in the canvas.
  67253. * @param subMesh Defines the sumesh to render
  67254. * @param batch Defines the batch of meshes in case of instances
  67255. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67256. */
  67257. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67258. /**
  67259. * Returns whether or not the outline renderer is ready for a given submesh.
  67260. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67261. * @param subMesh Defines the submesh to check readyness for
  67262. * @param useInstances Defines wheter wee are trying to render instances or not
  67263. * @returns true if ready otherwise false
  67264. */
  67265. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67266. private _beforeRenderingMesh;
  67267. private _afterRenderingMesh;
  67268. }
  67269. }
  67270. declare module BABYLON {
  67271. /**
  67272. * Defines the basic options interface of a Sprite Frame Source Size.
  67273. */
  67274. export interface ISpriteJSONSpriteSourceSize {
  67275. /**
  67276. * number of the original width of the Frame
  67277. */
  67278. w: number;
  67279. /**
  67280. * number of the original height of the Frame
  67281. */
  67282. h: number;
  67283. }
  67284. /**
  67285. * Defines the basic options interface of a Sprite Frame Data.
  67286. */
  67287. export interface ISpriteJSONSpriteFrameData {
  67288. /**
  67289. * number of the x offset of the Frame
  67290. */
  67291. x: number;
  67292. /**
  67293. * number of the y offset of the Frame
  67294. */
  67295. y: number;
  67296. /**
  67297. * number of the width of the Frame
  67298. */
  67299. w: number;
  67300. /**
  67301. * number of the height of the Frame
  67302. */
  67303. h: number;
  67304. }
  67305. /**
  67306. * Defines the basic options interface of a JSON Sprite.
  67307. */
  67308. export interface ISpriteJSONSprite {
  67309. /**
  67310. * string name of the Frame
  67311. */
  67312. filename: string;
  67313. /**
  67314. * ISpriteJSONSpriteFrame basic object of the frame data
  67315. */
  67316. frame: ISpriteJSONSpriteFrameData;
  67317. /**
  67318. * boolean to flag is the frame was rotated.
  67319. */
  67320. rotated: boolean;
  67321. /**
  67322. * boolean to flag is the frame was trimmed.
  67323. */
  67324. trimmed: boolean;
  67325. /**
  67326. * ISpriteJSONSpriteFrame basic object of the source data
  67327. */
  67328. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67329. /**
  67330. * ISpriteJSONSpriteFrame basic object of the source data
  67331. */
  67332. sourceSize: ISpriteJSONSpriteSourceSize;
  67333. }
  67334. /**
  67335. * Defines the basic options interface of a JSON atlas.
  67336. */
  67337. export interface ISpriteJSONAtlas {
  67338. /**
  67339. * Array of objects that contain the frame data.
  67340. */
  67341. frames: Array<ISpriteJSONSprite>;
  67342. /**
  67343. * object basic object containing the sprite meta data.
  67344. */
  67345. meta?: object;
  67346. }
  67347. }
  67348. declare module BABYLON {
  67349. /** @hidden */
  67350. export var spriteMapPixelShader: {
  67351. name: string;
  67352. shader: string;
  67353. };
  67354. }
  67355. declare module BABYLON {
  67356. /** @hidden */
  67357. export var spriteMapVertexShader: {
  67358. name: string;
  67359. shader: string;
  67360. };
  67361. }
  67362. declare module BABYLON {
  67363. /**
  67364. * Defines the basic options interface of a SpriteMap
  67365. */
  67366. export interface ISpriteMapOptions {
  67367. /**
  67368. * Vector2 of the number of cells in the grid.
  67369. */
  67370. stageSize?: Vector2;
  67371. /**
  67372. * Vector2 of the size of the output plane in World Units.
  67373. */
  67374. outputSize?: Vector2;
  67375. /**
  67376. * Vector3 of the position of the output plane in World Units.
  67377. */
  67378. outputPosition?: Vector3;
  67379. /**
  67380. * Vector3 of the rotation of the output plane.
  67381. */
  67382. outputRotation?: Vector3;
  67383. /**
  67384. * number of layers that the system will reserve in resources.
  67385. */
  67386. layerCount?: number;
  67387. /**
  67388. * number of max animation frames a single cell will reserve in resources.
  67389. */
  67390. maxAnimationFrames?: number;
  67391. /**
  67392. * number cell index of the base tile when the system compiles.
  67393. */
  67394. baseTile?: number;
  67395. /**
  67396. * boolean flip the sprite after its been repositioned by the framing data.
  67397. */
  67398. flipU?: boolean;
  67399. /**
  67400. * Vector3 scalar of the global RGB values of the SpriteMap.
  67401. */
  67402. colorMultiply?: Vector3;
  67403. }
  67404. /**
  67405. * Defines the IDisposable interface in order to be cleanable from resources.
  67406. */
  67407. export interface ISpriteMap extends IDisposable {
  67408. /**
  67409. * String name of the SpriteMap.
  67410. */
  67411. name: string;
  67412. /**
  67413. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67414. */
  67415. atlasJSON: ISpriteJSONAtlas;
  67416. /**
  67417. * Texture of the SpriteMap.
  67418. */
  67419. spriteSheet: Texture;
  67420. /**
  67421. * The parameters to initialize the SpriteMap with.
  67422. */
  67423. options: ISpriteMapOptions;
  67424. }
  67425. /**
  67426. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67427. */
  67428. export class SpriteMap implements ISpriteMap {
  67429. /** The Name of the spriteMap */
  67430. name: string;
  67431. /** The JSON file with the frame and meta data */
  67432. atlasJSON: ISpriteJSONAtlas;
  67433. /** The systems Sprite Sheet Texture */
  67434. spriteSheet: Texture;
  67435. /** Arguments passed with the Constructor */
  67436. options: ISpriteMapOptions;
  67437. /** Public Sprite Storage array, parsed from atlasJSON */
  67438. sprites: Array<ISpriteJSONSprite>;
  67439. /** Returns the Number of Sprites in the System */
  67440. get spriteCount(): number;
  67441. /** Returns the Position of Output Plane*/
  67442. get position(): Vector3;
  67443. /** Returns the Position of Output Plane*/
  67444. set position(v: Vector3);
  67445. /** Returns the Rotation of Output Plane*/
  67446. get rotation(): Vector3;
  67447. /** Returns the Rotation of Output Plane*/
  67448. set rotation(v: Vector3);
  67449. /** Sets the AnimationMap*/
  67450. get animationMap(): RawTexture;
  67451. /** Sets the AnimationMap*/
  67452. set animationMap(v: RawTexture);
  67453. /** Scene that the SpriteMap was created in */
  67454. private _scene;
  67455. /** Texture Buffer of Float32 that holds tile frame data*/
  67456. private _frameMap;
  67457. /** Texture Buffers of Float32 that holds tileMap data*/
  67458. private _tileMaps;
  67459. /** Texture Buffer of Float32 that holds Animation Data*/
  67460. private _animationMap;
  67461. /** Custom ShaderMaterial Central to the System*/
  67462. private _material;
  67463. /** Custom ShaderMaterial Central to the System*/
  67464. private _output;
  67465. /** Systems Time Ticker*/
  67466. private _time;
  67467. /**
  67468. * Creates a new SpriteMap
  67469. * @param name defines the SpriteMaps Name
  67470. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67471. * @param spriteSheet is the Texture that the Sprites are on.
  67472. * @param options a basic deployment configuration
  67473. * @param scene The Scene that the map is deployed on
  67474. */
  67475. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67476. /**
  67477. * Returns tileID location
  67478. * @returns Vector2 the cell position ID
  67479. */
  67480. getTileID(): Vector2;
  67481. /**
  67482. * Gets the UV location of the mouse over the SpriteMap.
  67483. * @returns Vector2 the UV position of the mouse interaction
  67484. */
  67485. getMousePosition(): Vector2;
  67486. /**
  67487. * Creates the "frame" texture Buffer
  67488. * -------------------------------------
  67489. * Structure of frames
  67490. * "filename": "Falling-Water-2.png",
  67491. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67492. * "rotated": true,
  67493. * "trimmed": true,
  67494. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67495. * "sourceSize": {"w":32,"h":32}
  67496. * @returns RawTexture of the frameMap
  67497. */
  67498. private _createFrameBuffer;
  67499. /**
  67500. * Creates the tileMap texture Buffer
  67501. * @param buffer normally and array of numbers, or a false to generate from scratch
  67502. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67503. * @returns RawTexture of the tileMap
  67504. */
  67505. private _createTileBuffer;
  67506. /**
  67507. * Modifies the data of the tileMaps
  67508. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67509. * @param pos is the iVector2 Coordinates of the Tile
  67510. * @param tile The SpriteIndex of the new Tile
  67511. */
  67512. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67513. /**
  67514. * Creates the animationMap texture Buffer
  67515. * @param buffer normally and array of numbers, or a false to generate from scratch
  67516. * @returns RawTexture of the animationMap
  67517. */
  67518. private _createTileAnimationBuffer;
  67519. /**
  67520. * Modifies the data of the animationMap
  67521. * @param cellID is the Index of the Sprite
  67522. * @param _frame is the target Animation frame
  67523. * @param toCell is the Target Index of the next frame of the animation
  67524. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67525. * @param speed is a global scalar of the time variable on the map.
  67526. */
  67527. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67528. /**
  67529. * Exports the .tilemaps file
  67530. */
  67531. saveTileMaps(): void;
  67532. /**
  67533. * Imports the .tilemaps file
  67534. * @param url of the .tilemaps file
  67535. */
  67536. loadTileMaps(url: string): void;
  67537. /**
  67538. * Release associated resources
  67539. */
  67540. dispose(): void;
  67541. }
  67542. }
  67543. declare module BABYLON {
  67544. /**
  67545. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67546. * @see http://doc.babylonjs.com/babylon101/sprites
  67547. */
  67548. export class SpritePackedManager extends SpriteManager {
  67549. /** defines the packed manager's name */
  67550. name: string;
  67551. /**
  67552. * Creates a new sprite manager from a packed sprite sheet
  67553. * @param name defines the manager's name
  67554. * @param imgUrl defines the sprite sheet url
  67555. * @param capacity defines the maximum allowed number of sprites
  67556. * @param scene defines the hosting scene
  67557. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67558. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67559. * @param samplingMode defines the smapling mode to use with spritesheet
  67560. * @param fromPacked set to true; do not alter
  67561. */
  67562. constructor(
  67563. /** defines the packed manager's name */
  67564. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67565. }
  67566. }
  67567. declare module BABYLON {
  67568. /**
  67569. * Defines the list of states available for a task inside a AssetsManager
  67570. */
  67571. export enum AssetTaskState {
  67572. /**
  67573. * Initialization
  67574. */
  67575. INIT = 0,
  67576. /**
  67577. * Running
  67578. */
  67579. RUNNING = 1,
  67580. /**
  67581. * Done
  67582. */
  67583. DONE = 2,
  67584. /**
  67585. * Error
  67586. */
  67587. ERROR = 3
  67588. }
  67589. /**
  67590. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67591. */
  67592. export abstract class AbstractAssetTask {
  67593. /**
  67594. * Task name
  67595. */ name: string;
  67596. /**
  67597. * Callback called when the task is successful
  67598. */
  67599. onSuccess: (task: any) => void;
  67600. /**
  67601. * Callback called when the task is not successful
  67602. */
  67603. onError: (task: any, message?: string, exception?: any) => void;
  67604. /**
  67605. * Creates a new AssetsManager
  67606. * @param name defines the name of the task
  67607. */
  67608. constructor(
  67609. /**
  67610. * Task name
  67611. */ name: string);
  67612. private _isCompleted;
  67613. private _taskState;
  67614. private _errorObject;
  67615. /**
  67616. * Get if the task is completed
  67617. */
  67618. get isCompleted(): boolean;
  67619. /**
  67620. * Gets the current state of the task
  67621. */
  67622. get taskState(): AssetTaskState;
  67623. /**
  67624. * Gets the current error object (if task is in error)
  67625. */
  67626. get errorObject(): {
  67627. message?: string;
  67628. exception?: any;
  67629. };
  67630. /**
  67631. * Internal only
  67632. * @hidden
  67633. */
  67634. _setErrorObject(message?: string, exception?: any): void;
  67635. /**
  67636. * Execute the current task
  67637. * @param scene defines the scene where you want your assets to be loaded
  67638. * @param onSuccess is a callback called when the task is successfully executed
  67639. * @param onError is a callback called if an error occurs
  67640. */
  67641. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67642. /**
  67643. * Execute the current task
  67644. * @param scene defines the scene where you want your assets to be loaded
  67645. * @param onSuccess is a callback called when the task is successfully executed
  67646. * @param onError is a callback called if an error occurs
  67647. */
  67648. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67649. /**
  67650. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67651. * This can be used with failed tasks that have the reason for failure fixed.
  67652. */
  67653. reset(): void;
  67654. private onErrorCallback;
  67655. private onDoneCallback;
  67656. }
  67657. /**
  67658. * Define the interface used by progress events raised during assets loading
  67659. */
  67660. export interface IAssetsProgressEvent {
  67661. /**
  67662. * Defines the number of remaining tasks to process
  67663. */
  67664. remainingCount: number;
  67665. /**
  67666. * Defines the total number of tasks
  67667. */
  67668. totalCount: number;
  67669. /**
  67670. * Defines the task that was just processed
  67671. */
  67672. task: AbstractAssetTask;
  67673. }
  67674. /**
  67675. * Class used to share progress information about assets loading
  67676. */
  67677. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67678. /**
  67679. * Defines the number of remaining tasks to process
  67680. */
  67681. remainingCount: number;
  67682. /**
  67683. * Defines the total number of tasks
  67684. */
  67685. totalCount: number;
  67686. /**
  67687. * Defines the task that was just processed
  67688. */
  67689. task: AbstractAssetTask;
  67690. /**
  67691. * Creates a AssetsProgressEvent
  67692. * @param remainingCount defines the number of remaining tasks to process
  67693. * @param totalCount defines the total number of tasks
  67694. * @param task defines the task that was just processed
  67695. */
  67696. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67697. }
  67698. /**
  67699. * Define a task used by AssetsManager to load meshes
  67700. */
  67701. export class MeshAssetTask extends AbstractAssetTask {
  67702. /**
  67703. * Defines the name of the task
  67704. */
  67705. name: string;
  67706. /**
  67707. * Defines the list of mesh's names you want to load
  67708. */
  67709. meshesNames: any;
  67710. /**
  67711. * Defines the root url to use as a base to load your meshes and associated resources
  67712. */
  67713. rootUrl: string;
  67714. /**
  67715. * Defines the filename of the scene to load from
  67716. */
  67717. sceneFilename: string;
  67718. /**
  67719. * Gets the list of loaded meshes
  67720. */
  67721. loadedMeshes: Array<AbstractMesh>;
  67722. /**
  67723. * Gets the list of loaded particle systems
  67724. */
  67725. loadedParticleSystems: Array<IParticleSystem>;
  67726. /**
  67727. * Gets the list of loaded skeletons
  67728. */
  67729. loadedSkeletons: Array<Skeleton>;
  67730. /**
  67731. * Gets the list of loaded animation groups
  67732. */
  67733. loadedAnimationGroups: Array<AnimationGroup>;
  67734. /**
  67735. * Callback called when the task is successful
  67736. */
  67737. onSuccess: (task: MeshAssetTask) => void;
  67738. /**
  67739. * Callback called when the task is successful
  67740. */
  67741. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67742. /**
  67743. * Creates a new MeshAssetTask
  67744. * @param name defines the name of the task
  67745. * @param meshesNames defines the list of mesh's names you want to load
  67746. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67747. * @param sceneFilename defines the filename of the scene to load from
  67748. */
  67749. constructor(
  67750. /**
  67751. * Defines the name of the task
  67752. */
  67753. name: string,
  67754. /**
  67755. * Defines the list of mesh's names you want to load
  67756. */
  67757. meshesNames: any,
  67758. /**
  67759. * Defines the root url to use as a base to load your meshes and associated resources
  67760. */
  67761. rootUrl: string,
  67762. /**
  67763. * Defines the filename of the scene to load from
  67764. */
  67765. sceneFilename: string);
  67766. /**
  67767. * Execute the current task
  67768. * @param scene defines the scene where you want your assets to be loaded
  67769. * @param onSuccess is a callback called when the task is successfully executed
  67770. * @param onError is a callback called if an error occurs
  67771. */
  67772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67773. }
  67774. /**
  67775. * Define a task used by AssetsManager to load text content
  67776. */
  67777. export class TextFileAssetTask extends AbstractAssetTask {
  67778. /**
  67779. * Defines the name of the task
  67780. */
  67781. name: string;
  67782. /**
  67783. * Defines the location of the file to load
  67784. */
  67785. url: string;
  67786. /**
  67787. * Gets the loaded text string
  67788. */
  67789. text: string;
  67790. /**
  67791. * Callback called when the task is successful
  67792. */
  67793. onSuccess: (task: TextFileAssetTask) => void;
  67794. /**
  67795. * Callback called when the task is successful
  67796. */
  67797. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67798. /**
  67799. * Creates a new TextFileAssetTask object
  67800. * @param name defines the name of the task
  67801. * @param url defines the location of the file to load
  67802. */
  67803. constructor(
  67804. /**
  67805. * Defines the name of the task
  67806. */
  67807. name: string,
  67808. /**
  67809. * Defines the location of the file to load
  67810. */
  67811. url: string);
  67812. /**
  67813. * Execute the current task
  67814. * @param scene defines the scene where you want your assets to be loaded
  67815. * @param onSuccess is a callback called when the task is successfully executed
  67816. * @param onError is a callback called if an error occurs
  67817. */
  67818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67819. }
  67820. /**
  67821. * Define a task used by AssetsManager to load binary data
  67822. */
  67823. export class BinaryFileAssetTask extends AbstractAssetTask {
  67824. /**
  67825. * Defines the name of the task
  67826. */
  67827. name: string;
  67828. /**
  67829. * Defines the location of the file to load
  67830. */
  67831. url: string;
  67832. /**
  67833. * Gets the lodaded data (as an array buffer)
  67834. */
  67835. data: ArrayBuffer;
  67836. /**
  67837. * Callback called when the task is successful
  67838. */
  67839. onSuccess: (task: BinaryFileAssetTask) => void;
  67840. /**
  67841. * Callback called when the task is successful
  67842. */
  67843. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67844. /**
  67845. * Creates a new BinaryFileAssetTask object
  67846. * @param name defines the name of the new task
  67847. * @param url defines the location of the file to load
  67848. */
  67849. constructor(
  67850. /**
  67851. * Defines the name of the task
  67852. */
  67853. name: string,
  67854. /**
  67855. * Defines the location of the file to load
  67856. */
  67857. url: string);
  67858. /**
  67859. * Execute the current task
  67860. * @param scene defines the scene where you want your assets to be loaded
  67861. * @param onSuccess is a callback called when the task is successfully executed
  67862. * @param onError is a callback called if an error occurs
  67863. */
  67864. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67865. }
  67866. /**
  67867. * Define a task used by AssetsManager to load images
  67868. */
  67869. export class ImageAssetTask extends AbstractAssetTask {
  67870. /**
  67871. * Defines the name of the task
  67872. */
  67873. name: string;
  67874. /**
  67875. * Defines the location of the image to load
  67876. */
  67877. url: string;
  67878. /**
  67879. * Gets the loaded images
  67880. */
  67881. image: HTMLImageElement;
  67882. /**
  67883. * Callback called when the task is successful
  67884. */
  67885. onSuccess: (task: ImageAssetTask) => void;
  67886. /**
  67887. * Callback called when the task is successful
  67888. */
  67889. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67890. /**
  67891. * Creates a new ImageAssetTask
  67892. * @param name defines the name of the task
  67893. * @param url defines the location of the image to load
  67894. */
  67895. constructor(
  67896. /**
  67897. * Defines the name of the task
  67898. */
  67899. name: string,
  67900. /**
  67901. * Defines the location of the image to load
  67902. */
  67903. url: string);
  67904. /**
  67905. * Execute the current task
  67906. * @param scene defines the scene where you want your assets to be loaded
  67907. * @param onSuccess is a callback called when the task is successfully executed
  67908. * @param onError is a callback called if an error occurs
  67909. */
  67910. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67911. }
  67912. /**
  67913. * Defines the interface used by texture loading tasks
  67914. */
  67915. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67916. /**
  67917. * Gets the loaded texture
  67918. */
  67919. texture: TEX;
  67920. }
  67921. /**
  67922. * Define a task used by AssetsManager to load 2D textures
  67923. */
  67924. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67925. /**
  67926. * Defines the name of the task
  67927. */
  67928. name: string;
  67929. /**
  67930. * Defines the location of the file to load
  67931. */
  67932. url: string;
  67933. /**
  67934. * Defines if mipmap should not be generated (default is false)
  67935. */
  67936. noMipmap?: boolean | undefined;
  67937. /**
  67938. * Defines if texture must be inverted on Y axis (default is false)
  67939. */
  67940. invertY?: boolean | undefined;
  67941. /**
  67942. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67943. */
  67944. samplingMode: number;
  67945. /**
  67946. * Gets the loaded texture
  67947. */
  67948. texture: Texture;
  67949. /**
  67950. * Callback called when the task is successful
  67951. */
  67952. onSuccess: (task: TextureAssetTask) => void;
  67953. /**
  67954. * Callback called when the task is successful
  67955. */
  67956. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67957. /**
  67958. * Creates a new TextureAssetTask object
  67959. * @param name defines the name of the task
  67960. * @param url defines the location of the file to load
  67961. * @param noMipmap defines if mipmap should not be generated (default is false)
  67962. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67963. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67964. */
  67965. constructor(
  67966. /**
  67967. * Defines the name of the task
  67968. */
  67969. name: string,
  67970. /**
  67971. * Defines the location of the file to load
  67972. */
  67973. url: string,
  67974. /**
  67975. * Defines if mipmap should not be generated (default is false)
  67976. */
  67977. noMipmap?: boolean | undefined,
  67978. /**
  67979. * Defines if texture must be inverted on Y axis (default is false)
  67980. */
  67981. invertY?: boolean | undefined,
  67982. /**
  67983. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67984. */
  67985. samplingMode?: number);
  67986. /**
  67987. * Execute the current task
  67988. * @param scene defines the scene where you want your assets to be loaded
  67989. * @param onSuccess is a callback called when the task is successfully executed
  67990. * @param onError is a callback called if an error occurs
  67991. */
  67992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67993. }
  67994. /**
  67995. * Define a task used by AssetsManager to load cube textures
  67996. */
  67997. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67998. /**
  67999. * Defines the name of the task
  68000. */
  68001. name: string;
  68002. /**
  68003. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68004. */
  68005. url: string;
  68006. /**
  68007. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68008. */
  68009. extensions?: string[] | undefined;
  68010. /**
  68011. * Defines if mipmaps should not be generated (default is false)
  68012. */
  68013. noMipmap?: boolean | undefined;
  68014. /**
  68015. * Defines the explicit list of files (undefined by default)
  68016. */
  68017. files?: string[] | undefined;
  68018. /**
  68019. * Gets the loaded texture
  68020. */
  68021. texture: CubeTexture;
  68022. /**
  68023. * Callback called when the task is successful
  68024. */
  68025. onSuccess: (task: CubeTextureAssetTask) => void;
  68026. /**
  68027. * Callback called when the task is successful
  68028. */
  68029. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68030. /**
  68031. * Creates a new CubeTextureAssetTask
  68032. * @param name defines the name of the task
  68033. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68034. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68035. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68036. * @param files defines the explicit list of files (undefined by default)
  68037. */
  68038. constructor(
  68039. /**
  68040. * Defines the name of the task
  68041. */
  68042. name: string,
  68043. /**
  68044. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68045. */
  68046. url: string,
  68047. /**
  68048. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68049. */
  68050. extensions?: string[] | undefined,
  68051. /**
  68052. * Defines if mipmaps should not be generated (default is false)
  68053. */
  68054. noMipmap?: boolean | undefined,
  68055. /**
  68056. * Defines the explicit list of files (undefined by default)
  68057. */
  68058. files?: string[] | undefined);
  68059. /**
  68060. * Execute the current task
  68061. * @param scene defines the scene where you want your assets to be loaded
  68062. * @param onSuccess is a callback called when the task is successfully executed
  68063. * @param onError is a callback called if an error occurs
  68064. */
  68065. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68066. }
  68067. /**
  68068. * Define a task used by AssetsManager to load HDR cube textures
  68069. */
  68070. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68071. /**
  68072. * Defines the name of the task
  68073. */
  68074. name: string;
  68075. /**
  68076. * Defines the location of the file to load
  68077. */
  68078. url: string;
  68079. /**
  68080. * Defines the desired size (the more it increases the longer the generation will be)
  68081. */
  68082. size: number;
  68083. /**
  68084. * Defines if mipmaps should not be generated (default is false)
  68085. */
  68086. noMipmap: boolean;
  68087. /**
  68088. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68089. */
  68090. generateHarmonics: boolean;
  68091. /**
  68092. * 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)
  68093. */
  68094. gammaSpace: boolean;
  68095. /**
  68096. * Internal Use Only
  68097. */
  68098. reserved: boolean;
  68099. /**
  68100. * Gets the loaded texture
  68101. */
  68102. texture: HDRCubeTexture;
  68103. /**
  68104. * Callback called when the task is successful
  68105. */
  68106. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68107. /**
  68108. * Callback called when the task is successful
  68109. */
  68110. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68111. /**
  68112. * Creates a new HDRCubeTextureAssetTask object
  68113. * @param name defines the name of the task
  68114. * @param url defines the location of the file to load
  68115. * @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.
  68116. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68117. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68118. * @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)
  68119. * @param reserved Internal use only
  68120. */
  68121. constructor(
  68122. /**
  68123. * Defines the name of the task
  68124. */
  68125. name: string,
  68126. /**
  68127. * Defines the location of the file to load
  68128. */
  68129. url: string,
  68130. /**
  68131. * Defines the desired size (the more it increases the longer the generation will be)
  68132. */
  68133. size: number,
  68134. /**
  68135. * Defines if mipmaps should not be generated (default is false)
  68136. */
  68137. noMipmap?: boolean,
  68138. /**
  68139. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68140. */
  68141. generateHarmonics?: boolean,
  68142. /**
  68143. * 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)
  68144. */
  68145. gammaSpace?: boolean,
  68146. /**
  68147. * Internal Use Only
  68148. */
  68149. reserved?: boolean);
  68150. /**
  68151. * Execute the current task
  68152. * @param scene defines the scene where you want your assets to be loaded
  68153. * @param onSuccess is a callback called when the task is successfully executed
  68154. * @param onError is a callback called if an error occurs
  68155. */
  68156. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68157. }
  68158. /**
  68159. * Define a task used by AssetsManager to load Equirectangular cube textures
  68160. */
  68161. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68162. /**
  68163. * Defines the name of the task
  68164. */
  68165. name: string;
  68166. /**
  68167. * Defines the location of the file to load
  68168. */
  68169. url: string;
  68170. /**
  68171. * Defines the desired size (the more it increases the longer the generation will be)
  68172. */
  68173. size: number;
  68174. /**
  68175. * Defines if mipmaps should not be generated (default is false)
  68176. */
  68177. noMipmap: boolean;
  68178. /**
  68179. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68180. * but the standard material would require them in Gamma space) (default is true)
  68181. */
  68182. gammaSpace: boolean;
  68183. /**
  68184. * Gets the loaded texture
  68185. */
  68186. texture: EquiRectangularCubeTexture;
  68187. /**
  68188. * Callback called when the task is successful
  68189. */
  68190. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68191. /**
  68192. * Callback called when the task is successful
  68193. */
  68194. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68195. /**
  68196. * Creates a new EquiRectangularCubeTextureAssetTask object
  68197. * @param name defines the name of the task
  68198. * @param url defines the location of the file to load
  68199. * @param size defines the desired size (the more it increases the longer the generation will be)
  68200. * If the size is omitted this implies you are using a preprocessed cubemap.
  68201. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68202. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68203. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68204. * (default is true)
  68205. */
  68206. constructor(
  68207. /**
  68208. * Defines the name of the task
  68209. */
  68210. name: string,
  68211. /**
  68212. * Defines the location of the file to load
  68213. */
  68214. url: string,
  68215. /**
  68216. * Defines the desired size (the more it increases the longer the generation will be)
  68217. */
  68218. size: number,
  68219. /**
  68220. * Defines if mipmaps should not be generated (default is false)
  68221. */
  68222. noMipmap?: boolean,
  68223. /**
  68224. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68225. * but the standard material would require them in Gamma space) (default is true)
  68226. */
  68227. gammaSpace?: boolean);
  68228. /**
  68229. * Execute the current task
  68230. * @param scene defines the scene where you want your assets to be loaded
  68231. * @param onSuccess is a callback called when the task is successfully executed
  68232. * @param onError is a callback called if an error occurs
  68233. */
  68234. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68235. }
  68236. /**
  68237. * This class can be used to easily import assets into a scene
  68238. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68239. */
  68240. export class AssetsManager {
  68241. private _scene;
  68242. private _isLoading;
  68243. protected _tasks: AbstractAssetTask[];
  68244. protected _waitingTasksCount: number;
  68245. protected _totalTasksCount: number;
  68246. /**
  68247. * Callback called when all tasks are processed
  68248. */
  68249. onFinish: (tasks: AbstractAssetTask[]) => void;
  68250. /**
  68251. * Callback called when a task is successful
  68252. */
  68253. onTaskSuccess: (task: AbstractAssetTask) => void;
  68254. /**
  68255. * Callback called when a task had an error
  68256. */
  68257. onTaskError: (task: AbstractAssetTask) => void;
  68258. /**
  68259. * Callback called when a task is done (whatever the result is)
  68260. */
  68261. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68262. /**
  68263. * Observable called when all tasks are processed
  68264. */
  68265. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68266. /**
  68267. * Observable called when a task had an error
  68268. */
  68269. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68270. /**
  68271. * Observable called when all tasks were executed
  68272. */
  68273. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68274. /**
  68275. * Observable called when a task is done (whatever the result is)
  68276. */
  68277. onProgressObservable: Observable<IAssetsProgressEvent>;
  68278. /**
  68279. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68281. */
  68282. useDefaultLoadingScreen: boolean;
  68283. /**
  68284. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68285. * when all assets have been downloaded.
  68286. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68287. */
  68288. autoHideLoadingUI: boolean;
  68289. /**
  68290. * Creates a new AssetsManager
  68291. * @param scene defines the scene to work on
  68292. */
  68293. constructor(scene: Scene);
  68294. /**
  68295. * Add a MeshAssetTask to the list of active tasks
  68296. * @param taskName defines the name of the new task
  68297. * @param meshesNames defines the name of meshes to load
  68298. * @param rootUrl defines the root url to use to locate files
  68299. * @param sceneFilename defines the filename of the scene file
  68300. * @returns a new MeshAssetTask object
  68301. */
  68302. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68303. /**
  68304. * Add a TextFileAssetTask to the list of active tasks
  68305. * @param taskName defines the name of the new task
  68306. * @param url defines the url of the file to load
  68307. * @returns a new TextFileAssetTask object
  68308. */
  68309. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68310. /**
  68311. * Add a BinaryFileAssetTask to the list of active tasks
  68312. * @param taskName defines the name of the new task
  68313. * @param url defines the url of the file to load
  68314. * @returns a new BinaryFileAssetTask object
  68315. */
  68316. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68317. /**
  68318. * Add a ImageAssetTask to the list of active tasks
  68319. * @param taskName defines the name of the new task
  68320. * @param url defines the url of the file to load
  68321. * @returns a new ImageAssetTask object
  68322. */
  68323. addImageTask(taskName: string, url: string): ImageAssetTask;
  68324. /**
  68325. * Add a TextureAssetTask to the list of active tasks
  68326. * @param taskName defines the name of the new task
  68327. * @param url defines the url of the file to load
  68328. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68329. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68330. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68331. * @returns a new TextureAssetTask object
  68332. */
  68333. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68334. /**
  68335. * Add a CubeTextureAssetTask to the list of active tasks
  68336. * @param taskName defines the name of the new task
  68337. * @param url defines the url of the file to load
  68338. * @param extensions defines the extension to use to load the cube map (can be null)
  68339. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68340. * @param files defines the list of files to load (can be null)
  68341. * @returns a new CubeTextureAssetTask object
  68342. */
  68343. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68344. /**
  68345. *
  68346. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68347. * @param taskName defines the name of the new task
  68348. * @param url defines the url of the file to load
  68349. * @param size defines the size you want for the cubemap (can be null)
  68350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68351. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68352. * @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)
  68353. * @param reserved Internal use only
  68354. * @returns a new HDRCubeTextureAssetTask object
  68355. */
  68356. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68357. /**
  68358. *
  68359. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68360. * @param taskName defines the name of the new task
  68361. * @param url defines the url of the file to load
  68362. * @param size defines the size you want for the cubemap (can be null)
  68363. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68364. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68365. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68366. * @returns a new EquiRectangularCubeTextureAssetTask object
  68367. */
  68368. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68369. /**
  68370. * Remove a task from the assets manager.
  68371. * @param task the task to remove
  68372. */
  68373. removeTask(task: AbstractAssetTask): void;
  68374. private _decreaseWaitingTasksCount;
  68375. private _runTask;
  68376. /**
  68377. * Reset the AssetsManager and remove all tasks
  68378. * @return the current instance of the AssetsManager
  68379. */
  68380. reset(): AssetsManager;
  68381. /**
  68382. * Start the loading process
  68383. * @return the current instance of the AssetsManager
  68384. */
  68385. load(): AssetsManager;
  68386. /**
  68387. * Start the loading process as an async operation
  68388. * @return a promise returning the list of failed tasks
  68389. */
  68390. loadAsync(): Promise<void>;
  68391. }
  68392. }
  68393. declare module BABYLON {
  68394. /**
  68395. * Wrapper class for promise with external resolve and reject.
  68396. */
  68397. export class Deferred<T> {
  68398. /**
  68399. * The promise associated with this deferred object.
  68400. */
  68401. readonly promise: Promise<T>;
  68402. private _resolve;
  68403. private _reject;
  68404. /**
  68405. * The resolve method of the promise associated with this deferred object.
  68406. */
  68407. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68408. /**
  68409. * The reject method of the promise associated with this deferred object.
  68410. */
  68411. get reject(): (reason?: any) => void;
  68412. /**
  68413. * Constructor for this deferred object.
  68414. */
  68415. constructor();
  68416. }
  68417. }
  68418. declare module BABYLON {
  68419. /**
  68420. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68421. */
  68422. export class MeshExploder {
  68423. private _centerMesh;
  68424. private _meshes;
  68425. private _meshesOrigins;
  68426. private _toCenterVectors;
  68427. private _scaledDirection;
  68428. private _newPosition;
  68429. private _centerPosition;
  68430. /**
  68431. * Explodes meshes from a center mesh.
  68432. * @param meshes The meshes to explode.
  68433. * @param centerMesh The mesh to be center of explosion.
  68434. */
  68435. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68436. private _setCenterMesh;
  68437. /**
  68438. * Get class name
  68439. * @returns "MeshExploder"
  68440. */
  68441. getClassName(): string;
  68442. /**
  68443. * "Exploded meshes"
  68444. * @returns Array of meshes with the centerMesh at index 0.
  68445. */
  68446. getMeshes(): Array<Mesh>;
  68447. /**
  68448. * Explodes meshes giving a specific direction
  68449. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68450. */
  68451. explode(direction?: number): void;
  68452. }
  68453. }
  68454. declare module BABYLON {
  68455. /**
  68456. * Class used to help managing file picking and drag'n'drop
  68457. */
  68458. export class FilesInput {
  68459. /**
  68460. * List of files ready to be loaded
  68461. */
  68462. static get FilesToLoad(): {
  68463. [key: string]: File;
  68464. };
  68465. /**
  68466. * Callback called when a file is processed
  68467. */
  68468. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68469. private _engine;
  68470. private _currentScene;
  68471. private _sceneLoadedCallback;
  68472. private _progressCallback;
  68473. private _additionalRenderLoopLogicCallback;
  68474. private _textureLoadingCallback;
  68475. private _startingProcessingFilesCallback;
  68476. private _onReloadCallback;
  68477. private _errorCallback;
  68478. private _elementToMonitor;
  68479. private _sceneFileToLoad;
  68480. private _filesToLoad;
  68481. /**
  68482. * Creates a new FilesInput
  68483. * @param engine defines the rendering engine
  68484. * @param scene defines the hosting scene
  68485. * @param sceneLoadedCallback callback called when scene is loaded
  68486. * @param progressCallback callback called to track progress
  68487. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68488. * @param textureLoadingCallback callback called when a texture is loading
  68489. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68490. * @param onReloadCallback callback called when a reload is requested
  68491. * @param errorCallback callback call if an error occurs
  68492. */
  68493. 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);
  68494. private _dragEnterHandler;
  68495. private _dragOverHandler;
  68496. private _dropHandler;
  68497. /**
  68498. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68499. * @param elementToMonitor defines the DOM element to track
  68500. */
  68501. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68502. /**
  68503. * Release all associated resources
  68504. */
  68505. dispose(): void;
  68506. private renderFunction;
  68507. private drag;
  68508. private drop;
  68509. private _traverseFolder;
  68510. private _processFiles;
  68511. /**
  68512. * Load files from a drop event
  68513. * @param event defines the drop event to use as source
  68514. */
  68515. loadFiles(event: any): void;
  68516. private _processReload;
  68517. /**
  68518. * Reload the current scene from the loaded files
  68519. */
  68520. reload(): void;
  68521. }
  68522. }
  68523. declare module BABYLON {
  68524. /**
  68525. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68527. */
  68528. export class SceneOptimization {
  68529. /**
  68530. * Defines the priority of this optimization (0 by default which means first in the list)
  68531. */
  68532. priority: number;
  68533. /**
  68534. * Gets a string describing the action executed by the current optimization
  68535. * @returns description string
  68536. */
  68537. getDescription(): string;
  68538. /**
  68539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68540. * @param scene defines the current scene where to apply this optimization
  68541. * @param optimizer defines the current optimizer
  68542. * @returns true if everything that can be done was applied
  68543. */
  68544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68545. /**
  68546. * Creates the SceneOptimization object
  68547. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68548. * @param desc defines the description associated with the optimization
  68549. */
  68550. constructor(
  68551. /**
  68552. * Defines the priority of this optimization (0 by default which means first in the list)
  68553. */
  68554. priority?: number);
  68555. }
  68556. /**
  68557. * Defines an optimization used to reduce the size of render target textures
  68558. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68559. */
  68560. export class TextureOptimization extends SceneOptimization {
  68561. /**
  68562. * Defines the priority of this optimization (0 by default which means first in the list)
  68563. */
  68564. priority: number;
  68565. /**
  68566. * 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
  68567. */
  68568. maximumSize: number;
  68569. /**
  68570. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68571. */
  68572. step: number;
  68573. /**
  68574. * Gets a string describing the action executed by the current optimization
  68575. * @returns description string
  68576. */
  68577. getDescription(): string;
  68578. /**
  68579. * Creates the TextureOptimization object
  68580. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68581. * @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
  68582. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68583. */
  68584. constructor(
  68585. /**
  68586. * Defines the priority of this optimization (0 by default which means first in the list)
  68587. */
  68588. priority?: number,
  68589. /**
  68590. * 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
  68591. */
  68592. maximumSize?: number,
  68593. /**
  68594. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68595. */
  68596. step?: number);
  68597. /**
  68598. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68599. * @param scene defines the current scene where to apply this optimization
  68600. * @param optimizer defines the current optimizer
  68601. * @returns true if everything that can be done was applied
  68602. */
  68603. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68604. }
  68605. /**
  68606. * Defines an optimization used to increase or decrease the rendering resolution
  68607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68608. */
  68609. export class HardwareScalingOptimization extends SceneOptimization {
  68610. /**
  68611. * Defines the priority of this optimization (0 by default which means first in the list)
  68612. */
  68613. priority: number;
  68614. /**
  68615. * Defines the maximum scale to use (2 by default)
  68616. */
  68617. maximumScale: number;
  68618. /**
  68619. * Defines the step to use between two passes (0.5 by default)
  68620. */
  68621. step: number;
  68622. private _currentScale;
  68623. private _directionOffset;
  68624. /**
  68625. * Gets a string describing the action executed by the current optimization
  68626. * @return description string
  68627. */
  68628. getDescription(): string;
  68629. /**
  68630. * Creates the HardwareScalingOptimization object
  68631. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68632. * @param maximumScale defines the maximum scale to use (2 by default)
  68633. * @param step defines the step to use between two passes (0.5 by default)
  68634. */
  68635. constructor(
  68636. /**
  68637. * Defines the priority of this optimization (0 by default which means first in the list)
  68638. */
  68639. priority?: number,
  68640. /**
  68641. * Defines the maximum scale to use (2 by default)
  68642. */
  68643. maximumScale?: number,
  68644. /**
  68645. * Defines the step to use between two passes (0.5 by default)
  68646. */
  68647. step?: number);
  68648. /**
  68649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68650. * @param scene defines the current scene where to apply this optimization
  68651. * @param optimizer defines the current optimizer
  68652. * @returns true if everything that can be done was applied
  68653. */
  68654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68655. }
  68656. /**
  68657. * Defines an optimization used to remove shadows
  68658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68659. */
  68660. export class ShadowsOptimization extends SceneOptimization {
  68661. /**
  68662. * Gets a string describing the action executed by the current optimization
  68663. * @return description string
  68664. */
  68665. getDescription(): string;
  68666. /**
  68667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68668. * @param scene defines the current scene where to apply this optimization
  68669. * @param optimizer defines the current optimizer
  68670. * @returns true if everything that can be done was applied
  68671. */
  68672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68673. }
  68674. /**
  68675. * Defines an optimization used to turn post-processes off
  68676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68677. */
  68678. export class PostProcessesOptimization extends SceneOptimization {
  68679. /**
  68680. * Gets a string describing the action executed by the current optimization
  68681. * @return description string
  68682. */
  68683. getDescription(): string;
  68684. /**
  68685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68686. * @param scene defines the current scene where to apply this optimization
  68687. * @param optimizer defines the current optimizer
  68688. * @returns true if everything that can be done was applied
  68689. */
  68690. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68691. }
  68692. /**
  68693. * Defines an optimization used to turn lens flares off
  68694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68695. */
  68696. export class LensFlaresOptimization extends SceneOptimization {
  68697. /**
  68698. * Gets a string describing the action executed by the current optimization
  68699. * @return description string
  68700. */
  68701. getDescription(): string;
  68702. /**
  68703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68704. * @param scene defines the current scene where to apply this optimization
  68705. * @param optimizer defines the current optimizer
  68706. * @returns true if everything that can be done was applied
  68707. */
  68708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68709. }
  68710. /**
  68711. * Defines an optimization based on user defined callback.
  68712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68713. */
  68714. export class CustomOptimization extends SceneOptimization {
  68715. /**
  68716. * Callback called to apply the custom optimization.
  68717. */
  68718. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68719. /**
  68720. * Callback called to get custom description
  68721. */
  68722. onGetDescription: () => string;
  68723. /**
  68724. * Gets a string describing the action executed by the current optimization
  68725. * @returns description string
  68726. */
  68727. getDescription(): string;
  68728. /**
  68729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68730. * @param scene defines the current scene where to apply this optimization
  68731. * @param optimizer defines the current optimizer
  68732. * @returns true if everything that can be done was applied
  68733. */
  68734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68735. }
  68736. /**
  68737. * Defines an optimization used to turn particles off
  68738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68739. */
  68740. export class ParticlesOptimization extends SceneOptimization {
  68741. /**
  68742. * Gets a string describing the action executed by the current optimization
  68743. * @return description string
  68744. */
  68745. getDescription(): string;
  68746. /**
  68747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68748. * @param scene defines the current scene where to apply this optimization
  68749. * @param optimizer defines the current optimizer
  68750. * @returns true if everything that can be done was applied
  68751. */
  68752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68753. }
  68754. /**
  68755. * Defines an optimization used to turn render targets off
  68756. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68757. */
  68758. export class RenderTargetsOptimization extends SceneOptimization {
  68759. /**
  68760. * Gets a string describing the action executed by the current optimization
  68761. * @return description string
  68762. */
  68763. getDescription(): string;
  68764. /**
  68765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68766. * @param scene defines the current scene where to apply this optimization
  68767. * @param optimizer defines the current optimizer
  68768. * @returns true if everything that can be done was applied
  68769. */
  68770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68771. }
  68772. /**
  68773. * Defines an optimization used to merge meshes with compatible materials
  68774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68775. */
  68776. export class MergeMeshesOptimization extends SceneOptimization {
  68777. private static _UpdateSelectionTree;
  68778. /**
  68779. * Gets or sets a boolean which defines if optimization octree has to be updated
  68780. */
  68781. static get UpdateSelectionTree(): boolean;
  68782. /**
  68783. * Gets or sets a boolean which defines if optimization octree has to be updated
  68784. */
  68785. static set UpdateSelectionTree(value: boolean);
  68786. /**
  68787. * Gets a string describing the action executed by the current optimization
  68788. * @return description string
  68789. */
  68790. getDescription(): string;
  68791. private _canBeMerged;
  68792. /**
  68793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68794. * @param scene defines the current scene where to apply this optimization
  68795. * @param optimizer defines the current optimizer
  68796. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68797. * @returns true if everything that can be done was applied
  68798. */
  68799. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68800. }
  68801. /**
  68802. * Defines a list of options used by SceneOptimizer
  68803. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68804. */
  68805. export class SceneOptimizerOptions {
  68806. /**
  68807. * Defines the target frame rate to reach (60 by default)
  68808. */
  68809. targetFrameRate: number;
  68810. /**
  68811. * Defines the interval between two checkes (2000ms by default)
  68812. */
  68813. trackerDuration: number;
  68814. /**
  68815. * Gets the list of optimizations to apply
  68816. */
  68817. optimizations: SceneOptimization[];
  68818. /**
  68819. * Creates a new list of options used by SceneOptimizer
  68820. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68821. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68822. */
  68823. constructor(
  68824. /**
  68825. * Defines the target frame rate to reach (60 by default)
  68826. */
  68827. targetFrameRate?: number,
  68828. /**
  68829. * Defines the interval between two checkes (2000ms by default)
  68830. */
  68831. trackerDuration?: number);
  68832. /**
  68833. * Add a new optimization
  68834. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68835. * @returns the current SceneOptimizerOptions
  68836. */
  68837. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68838. /**
  68839. * Add a new custom optimization
  68840. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68841. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68842. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68843. * @returns the current SceneOptimizerOptions
  68844. */
  68845. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68846. /**
  68847. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68848. * @param targetFrameRate defines the target frame rate (60 by default)
  68849. * @returns a SceneOptimizerOptions object
  68850. */
  68851. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68852. /**
  68853. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68854. * @param targetFrameRate defines the target frame rate (60 by default)
  68855. * @returns a SceneOptimizerOptions object
  68856. */
  68857. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68858. /**
  68859. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68860. * @param targetFrameRate defines the target frame rate (60 by default)
  68861. * @returns a SceneOptimizerOptions object
  68862. */
  68863. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68864. }
  68865. /**
  68866. * Class used to run optimizations in order to reach a target frame rate
  68867. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68868. */
  68869. export class SceneOptimizer implements IDisposable {
  68870. private _isRunning;
  68871. private _options;
  68872. private _scene;
  68873. private _currentPriorityLevel;
  68874. private _targetFrameRate;
  68875. private _trackerDuration;
  68876. private _currentFrameRate;
  68877. private _sceneDisposeObserver;
  68878. private _improvementMode;
  68879. /**
  68880. * Defines an observable called when the optimizer reaches the target frame rate
  68881. */
  68882. onSuccessObservable: Observable<SceneOptimizer>;
  68883. /**
  68884. * Defines an observable called when the optimizer enables an optimization
  68885. */
  68886. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68887. /**
  68888. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68889. */
  68890. onFailureObservable: Observable<SceneOptimizer>;
  68891. /**
  68892. * Gets a boolean indicating if the optimizer is in improvement mode
  68893. */
  68894. get isInImprovementMode(): boolean;
  68895. /**
  68896. * Gets the current priority level (0 at start)
  68897. */
  68898. get currentPriorityLevel(): number;
  68899. /**
  68900. * Gets the current frame rate checked by the SceneOptimizer
  68901. */
  68902. get currentFrameRate(): number;
  68903. /**
  68904. * Gets or sets the current target frame rate (60 by default)
  68905. */
  68906. get targetFrameRate(): number;
  68907. /**
  68908. * Gets or sets the current target frame rate (60 by default)
  68909. */
  68910. set targetFrameRate(value: number);
  68911. /**
  68912. * Gets or sets the current interval between two checks (every 2000ms by default)
  68913. */
  68914. get trackerDuration(): number;
  68915. /**
  68916. * Gets or sets the current interval between two checks (every 2000ms by default)
  68917. */
  68918. set trackerDuration(value: number);
  68919. /**
  68920. * Gets the list of active optimizations
  68921. */
  68922. get optimizations(): SceneOptimization[];
  68923. /**
  68924. * Creates a new SceneOptimizer
  68925. * @param scene defines the scene to work on
  68926. * @param options defines the options to use with the SceneOptimizer
  68927. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68928. * @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)
  68929. */
  68930. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68931. /**
  68932. * Stops the current optimizer
  68933. */
  68934. stop(): void;
  68935. /**
  68936. * Reset the optimizer to initial step (current priority level = 0)
  68937. */
  68938. reset(): void;
  68939. /**
  68940. * Start the optimizer. By default it will try to reach a specific framerate
  68941. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68942. */
  68943. start(): void;
  68944. private _checkCurrentState;
  68945. /**
  68946. * Release all resources
  68947. */
  68948. dispose(): void;
  68949. /**
  68950. * Helper function to create a SceneOptimizer with one single line of code
  68951. * @param scene defines the scene to work on
  68952. * @param options defines the options to use with the SceneOptimizer
  68953. * @param onSuccess defines a callback to call on success
  68954. * @param onFailure defines a callback to call on failure
  68955. * @returns the new SceneOptimizer object
  68956. */
  68957. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68958. }
  68959. }
  68960. declare module BABYLON {
  68961. /**
  68962. * Class used to serialize a scene into a string
  68963. */
  68964. export class SceneSerializer {
  68965. /**
  68966. * Clear cache used by a previous serialization
  68967. */
  68968. static ClearCache(): void;
  68969. /**
  68970. * Serialize a scene into a JSON compatible object
  68971. * @param scene defines the scene to serialize
  68972. * @returns a JSON compatible object
  68973. */
  68974. static Serialize(scene: Scene): any;
  68975. /**
  68976. * Serialize a mesh into a JSON compatible object
  68977. * @param toSerialize defines the mesh to serialize
  68978. * @param withParents defines if parents must be serialized as well
  68979. * @param withChildren defines if children must be serialized as well
  68980. * @returns a JSON compatible object
  68981. */
  68982. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68983. }
  68984. }
  68985. declare module BABYLON {
  68986. /**
  68987. * Class used to host texture specific utilities
  68988. */
  68989. export class TextureTools {
  68990. /**
  68991. * Uses the GPU to create a copy texture rescaled at a given size
  68992. * @param texture Texture to copy from
  68993. * @param width defines the desired width
  68994. * @param height defines the desired height
  68995. * @param useBilinearMode defines if bilinear mode has to be used
  68996. * @return the generated texture
  68997. */
  68998. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68999. }
  69000. }
  69001. declare module BABYLON {
  69002. /**
  69003. * This represents the different options available for the video capture.
  69004. */
  69005. export interface VideoRecorderOptions {
  69006. /** Defines the mime type of the video. */
  69007. mimeType: string;
  69008. /** Defines the FPS the video should be recorded at. */
  69009. fps: number;
  69010. /** Defines the chunk size for the recording data. */
  69011. recordChunckSize: number;
  69012. /** The audio tracks to attach to the recording. */
  69013. audioTracks?: MediaStreamTrack[];
  69014. }
  69015. /**
  69016. * This can help with recording videos from BabylonJS.
  69017. * This is based on the available WebRTC functionalities of the browser.
  69018. *
  69019. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69020. */
  69021. export class VideoRecorder {
  69022. private static readonly _defaultOptions;
  69023. /**
  69024. * Returns whether or not the VideoRecorder is available in your browser.
  69025. * @param engine Defines the Babylon Engine.
  69026. * @returns true if supported otherwise false.
  69027. */
  69028. static IsSupported(engine: Engine): boolean;
  69029. private readonly _options;
  69030. private _canvas;
  69031. private _mediaRecorder;
  69032. private _recordedChunks;
  69033. private _fileName;
  69034. private _resolve;
  69035. private _reject;
  69036. /**
  69037. * True when a recording is already in progress.
  69038. */
  69039. get isRecording(): boolean;
  69040. /**
  69041. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69042. * @param engine Defines the BabylonJS Engine you wish to record.
  69043. * @param options Defines options that can be used to customize the capture.
  69044. */
  69045. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69046. /**
  69047. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69048. */
  69049. stopRecording(): void;
  69050. /**
  69051. * Starts recording the canvas for a max duration specified in parameters.
  69052. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69053. * If null no automatic download will start and you can rely on the promise to get the data back.
  69054. * @param maxDuration Defines the maximum recording time in seconds.
  69055. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69056. * @return A promise callback at the end of the recording with the video data in Blob.
  69057. */
  69058. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69059. /**
  69060. * Releases internal resources used during the recording.
  69061. */
  69062. dispose(): void;
  69063. private _handleDataAvailable;
  69064. private _handleError;
  69065. private _handleStop;
  69066. }
  69067. }
  69068. declare module BABYLON {
  69069. /**
  69070. * Class containing a set of static utilities functions for screenshots
  69071. */
  69072. export class ScreenshotTools {
  69073. /**
  69074. * Captures a screenshot of the current rendering
  69075. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69076. * @param engine defines the rendering engine
  69077. * @param camera defines the source camera
  69078. * @param size This parameter can be set to a single number or to an object with the
  69079. * following (optional) properties: precision, width, height. If a single number is passed,
  69080. * it will be used for both width and height. If an object is passed, the screenshot size
  69081. * will be derived from the parameters. The precision property is a multiplier allowing
  69082. * rendering at a higher or lower resolution
  69083. * @param successCallback defines the callback receives a single parameter which contains the
  69084. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69085. * src parameter of an <img> to display it
  69086. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69087. * Check your browser for supported MIME types
  69088. */
  69089. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69090. /**
  69091. * Captures a screenshot of the current rendering
  69092. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69093. * @param engine defines the rendering engine
  69094. * @param camera defines the source camera
  69095. * @param size This parameter can be set to a single number or to an object with the
  69096. * following (optional) properties: precision, width, height. If a single number is passed,
  69097. * it will be used for both width and height. If an object is passed, the screenshot size
  69098. * will be derived from the parameters. The precision property is a multiplier allowing
  69099. * rendering at a higher or lower resolution
  69100. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69101. * Check your browser for supported MIME types
  69102. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69103. * to the src parameter of an <img> to display it
  69104. */
  69105. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69106. /**
  69107. * Generates an image screenshot from the specified camera.
  69108. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69109. * @param engine The engine to use for rendering
  69110. * @param camera The camera to use for rendering
  69111. * @param size This parameter can be set to a single number or to an object with the
  69112. * following (optional) properties: precision, width, height. If a single number is passed,
  69113. * it will be used for both width and height. If an object is passed, the screenshot size
  69114. * will be derived from the parameters. The precision property is a multiplier allowing
  69115. * rendering at a higher or lower resolution
  69116. * @param successCallback The callback receives a single parameter which contains the
  69117. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69118. * src parameter of an <img> to display it
  69119. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69120. * Check your browser for supported MIME types
  69121. * @param samples Texture samples (default: 1)
  69122. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69123. * @param fileName A name for for the downloaded file.
  69124. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69125. */
  69126. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69127. /**
  69128. * Generates an image screenshot from the specified camera.
  69129. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69130. * @param engine The engine to use for rendering
  69131. * @param camera The camera to use for rendering
  69132. * @param size This parameter can be set to a single number or to an object with the
  69133. * following (optional) properties: precision, width, height. If a single number is passed,
  69134. * it will be used for both width and height. If an object is passed, the screenshot size
  69135. * will be derived from the parameters. The precision property is a multiplier allowing
  69136. * rendering at a higher or lower resolution
  69137. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69138. * Check your browser for supported MIME types
  69139. * @param samples Texture samples (default: 1)
  69140. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69141. * @param fileName A name for for the downloaded file.
  69142. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69143. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69144. * to the src parameter of an <img> to display it
  69145. */
  69146. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69147. /**
  69148. * Gets height and width for screenshot size
  69149. * @private
  69150. */
  69151. private static _getScreenshotSize;
  69152. }
  69153. }
  69154. declare module BABYLON {
  69155. /**
  69156. * Interface for a data buffer
  69157. */
  69158. export interface IDataBuffer {
  69159. /**
  69160. * Reads bytes from the data buffer.
  69161. * @param byteOffset The byte offset to read
  69162. * @param byteLength The byte length to read
  69163. * @returns A promise that resolves when the bytes are read
  69164. */
  69165. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69166. /**
  69167. * The byte length of the buffer.
  69168. */
  69169. readonly byteLength: number;
  69170. }
  69171. /**
  69172. * Utility class for reading from a data buffer
  69173. */
  69174. export class DataReader {
  69175. /**
  69176. * The data buffer associated with this data reader.
  69177. */
  69178. readonly buffer: IDataBuffer;
  69179. /**
  69180. * The current byte offset from the beginning of the data buffer.
  69181. */
  69182. byteOffset: number;
  69183. private _dataView;
  69184. private _dataByteOffset;
  69185. /**
  69186. * Constructor
  69187. * @param buffer The buffer to read
  69188. */
  69189. constructor(buffer: IDataBuffer);
  69190. /**
  69191. * Loads the given byte length.
  69192. * @param byteLength The byte length to load
  69193. * @returns A promise that resolves when the load is complete
  69194. */
  69195. loadAsync(byteLength: number): Promise<void>;
  69196. /**
  69197. * Read a unsigned 32-bit integer from the currently loaded data range.
  69198. * @returns The 32-bit integer read
  69199. */
  69200. readUint32(): number;
  69201. /**
  69202. * Read a byte array from the currently loaded data range.
  69203. * @param byteLength The byte length to read
  69204. * @returns The byte array read
  69205. */
  69206. readUint8Array(byteLength: number): Uint8Array;
  69207. /**
  69208. * Read a string from the currently loaded data range.
  69209. * @param byteLength The byte length to read
  69210. * @returns The string read
  69211. */
  69212. readString(byteLength: number): string;
  69213. /**
  69214. * Skips the given byte length the currently loaded data range.
  69215. * @param byteLength The byte length to skip
  69216. */
  69217. skipBytes(byteLength: number): void;
  69218. }
  69219. }
  69220. declare module BABYLON {
  69221. /**
  69222. * Class for storing data to local storage if available or in-memory storage otherwise
  69223. */
  69224. export class DataStorage {
  69225. private static _Storage;
  69226. private static _GetStorage;
  69227. /**
  69228. * Reads a string from the data storage
  69229. * @param key The key to read
  69230. * @param defaultValue The value if the key doesn't exist
  69231. * @returns The string value
  69232. */
  69233. static ReadString(key: string, defaultValue: string): string;
  69234. /**
  69235. * Writes a string to the data storage
  69236. * @param key The key to write
  69237. * @param value The value to write
  69238. */
  69239. static WriteString(key: string, value: string): void;
  69240. /**
  69241. * Reads a boolean from the data storage
  69242. * @param key The key to read
  69243. * @param defaultValue The value if the key doesn't exist
  69244. * @returns The boolean value
  69245. */
  69246. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69247. /**
  69248. * Writes a boolean to the data storage
  69249. * @param key The key to write
  69250. * @param value The value to write
  69251. */
  69252. static WriteBoolean(key: string, value: boolean): void;
  69253. /**
  69254. * Reads a number from the data storage
  69255. * @param key The key to read
  69256. * @param defaultValue The value if the key doesn't exist
  69257. * @returns The number value
  69258. */
  69259. static ReadNumber(key: string, defaultValue: number): number;
  69260. /**
  69261. * Writes a number to the data storage
  69262. * @param key The key to write
  69263. * @param value The value to write
  69264. */
  69265. static WriteNumber(key: string, value: number): void;
  69266. }
  69267. }
  69268. declare module BABYLON {
  69269. /**
  69270. * Options used for hit testing
  69271. */
  69272. export interface IWebXRLegacyHitTestOptions {
  69273. /**
  69274. * Only test when user interacted with the scene. Default - hit test every frame
  69275. */
  69276. testOnPointerDownOnly?: boolean;
  69277. /**
  69278. * The node to use to transform the local results to world coordinates
  69279. */
  69280. worldParentNode?: TransformNode;
  69281. }
  69282. /**
  69283. * Interface defining the babylon result of raycasting/hit-test
  69284. */
  69285. export interface IWebXRLegacyHitResult {
  69286. /**
  69287. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69288. */
  69289. transformationMatrix: Matrix;
  69290. /**
  69291. * The native hit test result
  69292. */
  69293. xrHitResult: XRHitResult | XRHitTestResult;
  69294. }
  69295. /**
  69296. * The currently-working hit-test module.
  69297. * Hit test (or Ray-casting) is used to interact with the real world.
  69298. * For further information read here - https://github.com/immersive-web/hit-test
  69299. */
  69300. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69301. /**
  69302. * options to use when constructing this feature
  69303. */
  69304. readonly options: IWebXRLegacyHitTestOptions;
  69305. private _direction;
  69306. private _mat;
  69307. private _onSelectEnabled;
  69308. private _origin;
  69309. /**
  69310. * The module's name
  69311. */
  69312. static readonly Name: string;
  69313. /**
  69314. * The (Babylon) version of this module.
  69315. * This is an integer representing the implementation version.
  69316. * This number does not correspond to the WebXR specs version
  69317. */
  69318. static readonly Version: number;
  69319. /**
  69320. * Populated with the last native XR Hit Results
  69321. */
  69322. lastNativeXRHitResults: XRHitResult[];
  69323. /**
  69324. * Triggered when new babylon (transformed) hit test results are available
  69325. */
  69326. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69327. /**
  69328. * Creates a new instance of the (legacy version) hit test feature
  69329. * @param _xrSessionManager an instance of WebXRSessionManager
  69330. * @param options options to use when constructing this feature
  69331. */
  69332. constructor(_xrSessionManager: WebXRSessionManager,
  69333. /**
  69334. * options to use when constructing this feature
  69335. */
  69336. options?: IWebXRLegacyHitTestOptions);
  69337. /**
  69338. * execute a hit test with an XR Ray
  69339. *
  69340. * @param xrSession a native xrSession that will execute this hit test
  69341. * @param xrRay the ray (position and direction) to use for ray-casting
  69342. * @param referenceSpace native XR reference space to use for the hit-test
  69343. * @param filter filter function that will filter the results
  69344. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69345. */
  69346. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69347. /**
  69348. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69349. * @param event the (select) event to use to select with
  69350. * @param referenceSpace the reference space to use for this hit test
  69351. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69352. */
  69353. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69354. /**
  69355. * attach this feature
  69356. * Will usually be called by the features manager
  69357. *
  69358. * @returns true if successful.
  69359. */
  69360. attach(): boolean;
  69361. /**
  69362. * detach this feature.
  69363. * Will usually be called by the features manager
  69364. *
  69365. * @returns true if successful.
  69366. */
  69367. detach(): boolean;
  69368. /**
  69369. * Dispose this feature and all of the resources attached
  69370. */
  69371. dispose(): void;
  69372. protected _onXRFrame(frame: XRFrame): void;
  69373. private _onHitTestResults;
  69374. private _onSelect;
  69375. }
  69376. }
  69377. declare module BABYLON {
  69378. /**
  69379. * Options used in the plane detector module
  69380. */
  69381. export interface IWebXRPlaneDetectorOptions {
  69382. /**
  69383. * The node to use to transform the local results to world coordinates
  69384. */
  69385. worldParentNode?: TransformNode;
  69386. }
  69387. /**
  69388. * A babylon interface for a WebXR plane.
  69389. * A Plane is actually a polygon, built from N points in space
  69390. *
  69391. * Supported in chrome 79, not supported in canary 81 ATM
  69392. */
  69393. export interface IWebXRPlane {
  69394. /**
  69395. * a babylon-assigned ID for this polygon
  69396. */
  69397. id: number;
  69398. /**
  69399. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69400. */
  69401. polygonDefinition: Array<Vector3>;
  69402. /**
  69403. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69404. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69405. */
  69406. transformationMatrix: Matrix;
  69407. /**
  69408. * the native xr-plane object
  69409. */
  69410. xrPlane: XRPlane;
  69411. }
  69412. /**
  69413. * The plane detector is used to detect planes in the real world when in AR
  69414. * For more information see https://github.com/immersive-web/real-world-geometry/
  69415. */
  69416. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69417. private _options;
  69418. private _detectedPlanes;
  69419. private _enabled;
  69420. private _lastFrameDetected;
  69421. /**
  69422. * The module's name
  69423. */
  69424. static readonly Name: string;
  69425. /**
  69426. * The (Babylon) version of this module.
  69427. * This is an integer representing the implementation version.
  69428. * This number does not correspond to the WebXR specs version
  69429. */
  69430. static readonly Version: number;
  69431. /**
  69432. * Observers registered here will be executed when a new plane was added to the session
  69433. */
  69434. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69435. /**
  69436. * Observers registered here will be executed when a plane is no longer detected in the session
  69437. */
  69438. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69439. /**
  69440. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69441. * This can execute N times every frame
  69442. */
  69443. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69444. /**
  69445. * construct a new Plane Detector
  69446. * @param _xrSessionManager an instance of xr Session manager
  69447. * @param _options configuration to use when constructing this feature
  69448. */
  69449. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69450. /**
  69451. * Dispose this feature and all of the resources attached
  69452. */
  69453. dispose(): void;
  69454. protected _onXRFrame(frame: XRFrame): void;
  69455. private _init;
  69456. private _updatePlaneWithXRPlane;
  69457. /**
  69458. * avoiding using Array.find for global support.
  69459. * @param xrPlane the plane to find in the array
  69460. */
  69461. private findIndexInPlaneArray;
  69462. }
  69463. }
  69464. declare module BABYLON {
  69465. /**
  69466. * Configuration options of the anchor system
  69467. */
  69468. export interface IWebXRAnchorSystemOptions {
  69469. /**
  69470. * Should a new anchor be added every time a select event is triggered
  69471. */
  69472. addAnchorOnSelect?: boolean;
  69473. /**
  69474. * should the anchor system use plane detection.
  69475. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69476. */
  69477. usePlaneDetection?: boolean;
  69478. /**
  69479. * a node that will be used to convert local to world coordinates
  69480. */
  69481. worldParentNode?: TransformNode;
  69482. }
  69483. /**
  69484. * A babylon container for an XR Anchor
  69485. */
  69486. export interface IWebXRAnchor {
  69487. /**
  69488. * A babylon-assigned ID for this anchor
  69489. */
  69490. id: number;
  69491. /**
  69492. * Transformation matrix to apply to an object attached to this anchor
  69493. */
  69494. transformationMatrix: Matrix;
  69495. /**
  69496. * The native anchor object
  69497. */
  69498. xrAnchor: XRAnchor;
  69499. }
  69500. /**
  69501. * An implementation of the anchor system of WebXR.
  69502. * Note that the current documented implementation is not available in any browser. Future implementations
  69503. * will use the frame to create an anchor and not the session or a detected plane
  69504. * For further information see https://github.com/immersive-web/anchors/
  69505. */
  69506. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69507. private _options;
  69508. private _enabled;
  69509. private _hitTestModule;
  69510. private _lastFrameDetected;
  69511. private _onSelect;
  69512. private _planeDetector;
  69513. private _trackedAnchors;
  69514. /**
  69515. * The module's name
  69516. */
  69517. static readonly Name: string;
  69518. /**
  69519. * The (Babylon) version of this module.
  69520. * This is an integer representing the implementation version.
  69521. * This number does not correspond to the WebXR specs version
  69522. */
  69523. static readonly Version: number;
  69524. /**
  69525. * Observers registered here will be executed when a new anchor was added to the session
  69526. */
  69527. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69528. /**
  69529. * Observers registered here will be executed when an anchor was removed from the session
  69530. */
  69531. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69532. /**
  69533. * Observers registered here will be executed when an existing anchor updates
  69534. * This can execute N times every frame
  69535. */
  69536. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69537. /**
  69538. * constructs a new anchor system
  69539. * @param _xrSessionManager an instance of WebXRSessionManager
  69540. * @param _options configuration object for this feature
  69541. */
  69542. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69543. /**
  69544. * Add anchor at a specific XR point.
  69545. *
  69546. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69547. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69548. * @returns a promise the fulfills when the anchor was created
  69549. */
  69550. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69551. /**
  69552. * attach this feature
  69553. * Will usually be called by the features manager
  69554. *
  69555. * @returns true if successful.
  69556. */
  69557. attach(): boolean;
  69558. /**
  69559. * detach this feature.
  69560. * Will usually be called by the features manager
  69561. *
  69562. * @returns true if successful.
  69563. */
  69564. detach(): boolean;
  69565. /**
  69566. * Dispose this feature and all of the resources attached
  69567. */
  69568. dispose(): void;
  69569. /**
  69570. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69571. * @param hitTestModule the hit-test module to use.
  69572. */
  69573. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69574. /**
  69575. * set the plane detector to use in order to create anchors from frames
  69576. * @param planeDetector the plane-detector module to use
  69577. * @param enable enable plane-anchors. default is true
  69578. */
  69579. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69580. protected _onXRFrame(frame: XRFrame): void;
  69581. /**
  69582. * avoiding using Array.find for global support.
  69583. * @param xrAnchor the plane to find in the array
  69584. */
  69585. private _findIndexInAnchorArray;
  69586. private _updateAnchorWithXRFrame;
  69587. }
  69588. }
  69589. declare module BABYLON {
  69590. /**
  69591. * Options interface for the background remover plugin
  69592. */
  69593. export interface IWebXRBackgroundRemoverOptions {
  69594. /**
  69595. * Further background meshes to disable when entering AR
  69596. */
  69597. backgroundMeshes?: AbstractMesh[];
  69598. /**
  69599. * flags to configure the removal of the environment helper.
  69600. * If not set, the entire background will be removed. If set, flags should be set as well.
  69601. */
  69602. environmentHelperRemovalFlags?: {
  69603. /**
  69604. * Should the skybox be removed (default false)
  69605. */
  69606. skyBox?: boolean;
  69607. /**
  69608. * Should the ground be removed (default false)
  69609. */
  69610. ground?: boolean;
  69611. };
  69612. /**
  69613. * don't disable the environment helper
  69614. */
  69615. ignoreEnvironmentHelper?: boolean;
  69616. }
  69617. /**
  69618. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69619. */
  69620. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69621. /**
  69622. * read-only options to be used in this module
  69623. */
  69624. readonly options: IWebXRBackgroundRemoverOptions;
  69625. /**
  69626. * The module's name
  69627. */
  69628. static readonly Name: string;
  69629. /**
  69630. * The (Babylon) version of this module.
  69631. * This is an integer representing the implementation version.
  69632. * This number does not correspond to the WebXR specs version
  69633. */
  69634. static readonly Version: number;
  69635. /**
  69636. * registered observers will be triggered when the background state changes
  69637. */
  69638. onBackgroundStateChangedObservable: Observable<boolean>;
  69639. /**
  69640. * constructs a new background remover module
  69641. * @param _xrSessionManager the session manager for this module
  69642. * @param options read-only options to be used in this module
  69643. */
  69644. constructor(_xrSessionManager: WebXRSessionManager,
  69645. /**
  69646. * read-only options to be used in this module
  69647. */
  69648. options?: IWebXRBackgroundRemoverOptions);
  69649. /**
  69650. * attach this feature
  69651. * Will usually be called by the features manager
  69652. *
  69653. * @returns true if successful.
  69654. */
  69655. attach(): boolean;
  69656. /**
  69657. * detach this feature.
  69658. * Will usually be called by the features manager
  69659. *
  69660. * @returns true if successful.
  69661. */
  69662. detach(): boolean;
  69663. /**
  69664. * Dispose this feature and all of the resources attached
  69665. */
  69666. dispose(): void;
  69667. protected _onXRFrame(_xrFrame: XRFrame): void;
  69668. private _setBackgroundState;
  69669. }
  69670. }
  69671. declare module BABYLON {
  69672. /**
  69673. * Options for the controller physics feature
  69674. */
  69675. export class IWebXRControllerPhysicsOptions {
  69676. /**
  69677. * Should the headset get its own impostor
  69678. */
  69679. enableHeadsetImpostor?: boolean;
  69680. /**
  69681. * Optional parameters for the headset impostor
  69682. */
  69683. headsetImpostorParams?: {
  69684. /**
  69685. * The type of impostor to create. Default is sphere
  69686. */
  69687. impostorType: number;
  69688. /**
  69689. * the size of the impostor. Defaults to 10cm
  69690. */
  69691. impostorSize?: number | {
  69692. width: number;
  69693. height: number;
  69694. depth: number;
  69695. };
  69696. /**
  69697. * Friction definitions
  69698. */
  69699. friction?: number;
  69700. /**
  69701. * Restitution
  69702. */
  69703. restitution?: number;
  69704. };
  69705. /**
  69706. * The physics properties of the future impostors
  69707. */
  69708. physicsProperties?: {
  69709. /**
  69710. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69711. * Note that this requires a physics engine that supports mesh impostors!
  69712. */
  69713. useControllerMesh?: boolean;
  69714. /**
  69715. * The type of impostor to create. Default is sphere
  69716. */
  69717. impostorType?: number;
  69718. /**
  69719. * the size of the impostor. Defaults to 10cm
  69720. */
  69721. impostorSize?: number | {
  69722. width: number;
  69723. height: number;
  69724. depth: number;
  69725. };
  69726. /**
  69727. * Friction definitions
  69728. */
  69729. friction?: number;
  69730. /**
  69731. * Restitution
  69732. */
  69733. restitution?: number;
  69734. };
  69735. /**
  69736. * the xr input to use with this pointer selection
  69737. */
  69738. xrInput: WebXRInput;
  69739. }
  69740. /**
  69741. * Add physics impostor to your webxr controllers,
  69742. * including naive calculation of their linear and angular velocity
  69743. */
  69744. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69745. private readonly _options;
  69746. private _attachController;
  69747. private _controllers;
  69748. private _debugMode;
  69749. private _delta;
  69750. private _headsetImpostor?;
  69751. private _headsetMesh?;
  69752. private _lastTimestamp;
  69753. private _tmpQuaternion;
  69754. private _tmpVector;
  69755. /**
  69756. * The module's name
  69757. */
  69758. static readonly Name: string;
  69759. /**
  69760. * The (Babylon) version of this module.
  69761. * This is an integer representing the implementation version.
  69762. * This number does not correspond to the webxr specs version
  69763. */
  69764. static readonly Version: number;
  69765. /**
  69766. * Construct a new Controller Physics Feature
  69767. * @param _xrSessionManager the corresponding xr session manager
  69768. * @param _options options to create this feature with
  69769. */
  69770. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69771. /**
  69772. * @hidden
  69773. * enable debugging - will show console outputs and the impostor mesh
  69774. */
  69775. _enablePhysicsDebug(): void;
  69776. /**
  69777. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69778. * @param xrController the controller to add
  69779. */
  69780. addController(xrController: WebXRInputSource): void;
  69781. /**
  69782. * attach this feature
  69783. * Will usually be called by the features manager
  69784. *
  69785. * @returns true if successful.
  69786. */
  69787. attach(): boolean;
  69788. /**
  69789. * detach this feature.
  69790. * Will usually be called by the features manager
  69791. *
  69792. * @returns true if successful.
  69793. */
  69794. detach(): boolean;
  69795. /**
  69796. * Get the headset impostor, if enabled
  69797. * @returns the impostor
  69798. */
  69799. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69800. /**
  69801. * Get the physics impostor of a specific controller.
  69802. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69803. * @param controller the controller or the controller id of which to get the impostor
  69804. * @returns the impostor or null
  69805. */
  69806. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69807. /**
  69808. * Update the physics properties provided in the constructor
  69809. * @param newProperties the new properties object
  69810. */
  69811. setPhysicsProperties(newProperties: {
  69812. impostorType?: number;
  69813. impostorSize?: number | {
  69814. width: number;
  69815. height: number;
  69816. depth: number;
  69817. };
  69818. friction?: number;
  69819. restitution?: number;
  69820. }): void;
  69821. protected _onXRFrame(_xrFrame: any): void;
  69822. private _detachController;
  69823. }
  69824. }
  69825. declare module BABYLON {
  69826. /**
  69827. * Options used for hit testing (version 2)
  69828. */
  69829. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  69830. /**
  69831. * Do not create a permanent hit test. Will usually be used when only
  69832. * transient inputs are needed.
  69833. */
  69834. disablePermanentHitTest?: boolean;
  69835. /**
  69836. * Enable transient (for example touch-based) hit test inspections
  69837. */
  69838. enableTransientHitTest?: boolean;
  69839. /**
  69840. * Offset ray for the permanent hit test
  69841. */
  69842. offsetRay?: Vector3;
  69843. /**
  69844. * Offset ray for the transient hit test
  69845. */
  69846. transientOffsetRay?: Vector3;
  69847. /**
  69848. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  69849. */
  69850. useReferenceSpace?: boolean;
  69851. }
  69852. /**
  69853. * Interface defining the babylon result of hit-test
  69854. */
  69855. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  69856. /**
  69857. * The input source that generated this hit test (if transient)
  69858. */
  69859. inputSource?: XRInputSource;
  69860. /**
  69861. * Is this a transient hit test
  69862. */
  69863. isTransient?: boolean;
  69864. /**
  69865. * Position of the hit test result
  69866. */
  69867. position: Vector3;
  69868. /**
  69869. * Rotation of the hit test result
  69870. */
  69871. rotationQuaternion: Quaternion;
  69872. }
  69873. /**
  69874. * The currently-working hit-test module.
  69875. * Hit test (or Ray-casting) is used to interact with the real world.
  69876. * For further information read here - https://github.com/immersive-web/hit-test
  69877. *
  69878. * Tested on chrome (mobile) 80.
  69879. */
  69880. export class WebXRHitTest extends WebXRAbstractFeature {
  69881. /**
  69882. * options to use when constructing this feature
  69883. */
  69884. readonly options: IWebXRHitTestOptions;
  69885. private _tmpMat;
  69886. private _tmpPos;
  69887. private _tmpQuat;
  69888. private _transientXrHitTestSource;
  69889. private _xrHitTestSource;
  69890. private initHitTestSource;
  69891. /**
  69892. * The module's name
  69893. */
  69894. static readonly Name: string;
  69895. /**
  69896. * The (Babylon) version of this module.
  69897. * This is an integer representing the implementation version.
  69898. * This number does not correspond to the WebXR specs version
  69899. */
  69900. static readonly Version: number;
  69901. /**
  69902. * When set to true, each hit test will have its own position/rotation objects
  69903. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  69904. * the developers will clone them or copy them as they see fit.
  69905. */
  69906. autoCloneTransformation: boolean;
  69907. /**
  69908. * Populated with the last native XR Hit Results
  69909. */
  69910. lastNativeXRHitResults: XRHitResult[];
  69911. /**
  69912. * Triggered when new babylon (transformed) hit test results are available
  69913. */
  69914. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  69915. /**
  69916. * Use this to temporarily pause hit test checks.
  69917. */
  69918. paused: boolean;
  69919. /**
  69920. * Creates a new instance of the hit test feature
  69921. * @param _xrSessionManager an instance of WebXRSessionManager
  69922. * @param options options to use when constructing this feature
  69923. */
  69924. constructor(_xrSessionManager: WebXRSessionManager,
  69925. /**
  69926. * options to use when constructing this feature
  69927. */
  69928. options?: IWebXRHitTestOptions);
  69929. /**
  69930. * attach this feature
  69931. * Will usually be called by the features manager
  69932. *
  69933. * @returns true if successful.
  69934. */
  69935. attach(): boolean;
  69936. /**
  69937. * detach this feature.
  69938. * Will usually be called by the features manager
  69939. *
  69940. * @returns true if successful.
  69941. */
  69942. detach(): boolean;
  69943. /**
  69944. * Dispose this feature and all of the resources attached
  69945. */
  69946. dispose(): void;
  69947. protected _onXRFrame(frame: XRFrame): void;
  69948. private _processWebXRHitTestResult;
  69949. }
  69950. }
  69951. declare module BABYLON {
  69952. /**
  69953. * The motion controller class for all microsoft mixed reality controllers
  69954. */
  69955. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69956. protected readonly _mapping: {
  69957. defaultButton: {
  69958. "valueNodeName": string;
  69959. "unpressedNodeName": string;
  69960. "pressedNodeName": string;
  69961. };
  69962. defaultAxis: {
  69963. "valueNodeName": string;
  69964. "minNodeName": string;
  69965. "maxNodeName": string;
  69966. };
  69967. buttons: {
  69968. "xr-standard-trigger": {
  69969. "rootNodeName": string;
  69970. "componentProperty": string;
  69971. "states": string[];
  69972. };
  69973. "xr-standard-squeeze": {
  69974. "rootNodeName": string;
  69975. "componentProperty": string;
  69976. "states": string[];
  69977. };
  69978. "xr-standard-touchpad": {
  69979. "rootNodeName": string;
  69980. "labelAnchorNodeName": string;
  69981. "touchPointNodeName": string;
  69982. };
  69983. "xr-standard-thumbstick": {
  69984. "rootNodeName": string;
  69985. "componentProperty": string;
  69986. "states": string[];
  69987. };
  69988. };
  69989. axes: {
  69990. "xr-standard-touchpad": {
  69991. "x-axis": {
  69992. "rootNodeName": string;
  69993. };
  69994. "y-axis": {
  69995. "rootNodeName": string;
  69996. };
  69997. };
  69998. "xr-standard-thumbstick": {
  69999. "x-axis": {
  70000. "rootNodeName": string;
  70001. };
  70002. "y-axis": {
  70003. "rootNodeName": string;
  70004. };
  70005. };
  70006. };
  70007. };
  70008. /**
  70009. * The base url used to load the left and right controller models
  70010. */
  70011. static MODEL_BASE_URL: string;
  70012. /**
  70013. * The name of the left controller model file
  70014. */
  70015. static MODEL_LEFT_FILENAME: string;
  70016. /**
  70017. * The name of the right controller model file
  70018. */
  70019. static MODEL_RIGHT_FILENAME: string;
  70020. profileId: string;
  70021. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70022. protected _getFilenameAndPath(): {
  70023. filename: string;
  70024. path: string;
  70025. };
  70026. protected _getModelLoadingConstraints(): boolean;
  70027. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70028. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70029. protected _updateModel(): void;
  70030. }
  70031. }
  70032. declare module BABYLON {
  70033. /**
  70034. * The motion controller class for oculus touch (quest, rift).
  70035. * This class supports legacy mapping as well the standard xr mapping
  70036. */
  70037. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70038. private _forceLegacyControllers;
  70039. private _modelRootNode;
  70040. /**
  70041. * The base url used to load the left and right controller models
  70042. */
  70043. static MODEL_BASE_URL: string;
  70044. /**
  70045. * The name of the left controller model file
  70046. */
  70047. static MODEL_LEFT_FILENAME: string;
  70048. /**
  70049. * The name of the right controller model file
  70050. */
  70051. static MODEL_RIGHT_FILENAME: string;
  70052. /**
  70053. * Base Url for the Quest controller model.
  70054. */
  70055. static QUEST_MODEL_BASE_URL: string;
  70056. profileId: string;
  70057. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70058. protected _getFilenameAndPath(): {
  70059. filename: string;
  70060. path: string;
  70061. };
  70062. protected _getModelLoadingConstraints(): boolean;
  70063. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70064. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70065. protected _updateModel(): void;
  70066. /**
  70067. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70068. * between the touch and touch 2.
  70069. */
  70070. private _isQuest;
  70071. }
  70072. }
  70073. declare module BABYLON {
  70074. /**
  70075. * The motion controller class for the standard HTC-Vive controllers
  70076. */
  70077. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70078. private _modelRootNode;
  70079. /**
  70080. * The base url used to load the left and right controller models
  70081. */
  70082. static MODEL_BASE_URL: string;
  70083. /**
  70084. * File name for the controller model.
  70085. */
  70086. static MODEL_FILENAME: string;
  70087. profileId: string;
  70088. /**
  70089. * Create a new Vive motion controller object
  70090. * @param scene the scene to use to create this controller
  70091. * @param gamepadObject the corresponding gamepad object
  70092. * @param handness the handness of the controller
  70093. */
  70094. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70095. protected _getFilenameAndPath(): {
  70096. filename: string;
  70097. path: string;
  70098. };
  70099. protected _getModelLoadingConstraints(): boolean;
  70100. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70101. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70102. protected _updateModel(): void;
  70103. }
  70104. }
  70105. declare module BABYLON {
  70106. /**
  70107. * A cursor which tracks a point on a path
  70108. */
  70109. export class PathCursor {
  70110. private path;
  70111. /**
  70112. * Stores path cursor callbacks for when an onchange event is triggered
  70113. */
  70114. private _onchange;
  70115. /**
  70116. * The value of the path cursor
  70117. */
  70118. value: number;
  70119. /**
  70120. * The animation array of the path cursor
  70121. */
  70122. animations: Animation[];
  70123. /**
  70124. * Initializes the path cursor
  70125. * @param path The path to track
  70126. */
  70127. constructor(path: Path2);
  70128. /**
  70129. * Gets the cursor point on the path
  70130. * @returns A point on the path cursor at the cursor location
  70131. */
  70132. getPoint(): Vector3;
  70133. /**
  70134. * Moves the cursor ahead by the step amount
  70135. * @param step The amount to move the cursor forward
  70136. * @returns This path cursor
  70137. */
  70138. moveAhead(step?: number): PathCursor;
  70139. /**
  70140. * Moves the cursor behind by the step amount
  70141. * @param step The amount to move the cursor back
  70142. * @returns This path cursor
  70143. */
  70144. moveBack(step?: number): PathCursor;
  70145. /**
  70146. * Moves the cursor by the step amount
  70147. * If the step amount is greater than one, an exception is thrown
  70148. * @param step The amount to move the cursor
  70149. * @returns This path cursor
  70150. */
  70151. move(step: number): PathCursor;
  70152. /**
  70153. * Ensures that the value is limited between zero and one
  70154. * @returns This path cursor
  70155. */
  70156. private ensureLimits;
  70157. /**
  70158. * Runs onchange callbacks on change (used by the animation engine)
  70159. * @returns This path cursor
  70160. */
  70161. private raiseOnChange;
  70162. /**
  70163. * Executes a function on change
  70164. * @param f A path cursor onchange callback
  70165. * @returns This path cursor
  70166. */
  70167. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70168. }
  70169. }
  70170. declare module BABYLON {
  70171. /** @hidden */
  70172. export var blurPixelShader: {
  70173. name: string;
  70174. shader: string;
  70175. };
  70176. }
  70177. declare module BABYLON {
  70178. /** @hidden */
  70179. export var pointCloudVertexDeclaration: {
  70180. name: string;
  70181. shader: string;
  70182. };
  70183. }
  70184. // Mixins
  70185. interface Window {
  70186. mozIndexedDB: IDBFactory;
  70187. webkitIndexedDB: IDBFactory;
  70188. msIndexedDB: IDBFactory;
  70189. webkitURL: typeof URL;
  70190. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70191. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70192. WebGLRenderingContext: WebGLRenderingContext;
  70193. MSGesture: MSGesture;
  70194. CANNON: any;
  70195. AudioContext: AudioContext;
  70196. webkitAudioContext: AudioContext;
  70197. PointerEvent: any;
  70198. Math: Math;
  70199. Uint8Array: Uint8ArrayConstructor;
  70200. Float32Array: Float32ArrayConstructor;
  70201. mozURL: typeof URL;
  70202. msURL: typeof URL;
  70203. VRFrameData: any; // WebVR, from specs 1.1
  70204. DracoDecoderModule: any;
  70205. setImmediate(handler: (...args: any[]) => void): number;
  70206. }
  70207. interface HTMLCanvasElement {
  70208. requestPointerLock(): void;
  70209. msRequestPointerLock?(): void;
  70210. mozRequestPointerLock?(): void;
  70211. webkitRequestPointerLock?(): void;
  70212. /** Track wether a record is in progress */
  70213. isRecording: boolean;
  70214. /** Capture Stream method defined by some browsers */
  70215. captureStream(fps?: number): MediaStream;
  70216. }
  70217. interface CanvasRenderingContext2D {
  70218. msImageSmoothingEnabled: boolean;
  70219. }
  70220. interface MouseEvent {
  70221. mozMovementX: number;
  70222. mozMovementY: number;
  70223. webkitMovementX: number;
  70224. webkitMovementY: number;
  70225. msMovementX: number;
  70226. msMovementY: number;
  70227. }
  70228. interface Navigator {
  70229. mozGetVRDevices: (any: any) => any;
  70230. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70231. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70232. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70233. webkitGetGamepads(): Gamepad[];
  70234. msGetGamepads(): Gamepad[];
  70235. webkitGamepads(): Gamepad[];
  70236. }
  70237. interface HTMLVideoElement {
  70238. mozSrcObject: any;
  70239. }
  70240. interface Math {
  70241. fround(x: number): number;
  70242. imul(a: number, b: number): number;
  70243. }
  70244. interface WebGLRenderingContext {
  70245. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70246. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70247. vertexAttribDivisor(index: number, divisor: number): void;
  70248. createVertexArray(): any;
  70249. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70250. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70251. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70252. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70253. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70254. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70255. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70256. // Queries
  70257. createQuery(): WebGLQuery;
  70258. deleteQuery(query: WebGLQuery): void;
  70259. beginQuery(target: number, query: WebGLQuery): void;
  70260. endQuery(target: number): void;
  70261. getQueryParameter(query: WebGLQuery, pname: number): any;
  70262. getQuery(target: number, pname: number): any;
  70263. MAX_SAMPLES: number;
  70264. RGBA8: number;
  70265. READ_FRAMEBUFFER: number;
  70266. DRAW_FRAMEBUFFER: number;
  70267. UNIFORM_BUFFER: number;
  70268. HALF_FLOAT_OES: number;
  70269. RGBA16F: number;
  70270. RGBA32F: number;
  70271. R32F: number;
  70272. RG32F: number;
  70273. RGB32F: number;
  70274. R16F: number;
  70275. RG16F: number;
  70276. RGB16F: number;
  70277. RED: number;
  70278. RG: number;
  70279. R8: number;
  70280. RG8: number;
  70281. UNSIGNED_INT_24_8: number;
  70282. DEPTH24_STENCIL8: number;
  70283. MIN: number;
  70284. MAX: number;
  70285. /* Multiple Render Targets */
  70286. drawBuffers(buffers: number[]): void;
  70287. readBuffer(src: number): void;
  70288. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70289. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70290. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70291. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70292. // Occlusion Query
  70293. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70294. ANY_SAMPLES_PASSED: number;
  70295. QUERY_RESULT_AVAILABLE: number;
  70296. QUERY_RESULT: number;
  70297. }
  70298. interface WebGLProgram {
  70299. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70300. }
  70301. interface EXT_disjoint_timer_query {
  70302. QUERY_COUNTER_BITS_EXT: number;
  70303. TIME_ELAPSED_EXT: number;
  70304. TIMESTAMP_EXT: number;
  70305. GPU_DISJOINT_EXT: number;
  70306. QUERY_RESULT_EXT: number;
  70307. QUERY_RESULT_AVAILABLE_EXT: number;
  70308. queryCounterEXT(query: WebGLQuery, target: number): void;
  70309. createQueryEXT(): WebGLQuery;
  70310. beginQueryEXT(target: number, query: WebGLQuery): void;
  70311. endQueryEXT(target: number): void;
  70312. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70313. deleteQueryEXT(query: WebGLQuery): void;
  70314. }
  70315. interface WebGLUniformLocation {
  70316. _currentState: any;
  70317. }
  70318. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70319. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70320. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70321. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70322. interface WebGLRenderingContext {
  70323. readonly RASTERIZER_DISCARD: number;
  70324. readonly DEPTH_COMPONENT24: number;
  70325. readonly TEXTURE_3D: number;
  70326. readonly TEXTURE_2D_ARRAY: number;
  70327. readonly TEXTURE_COMPARE_FUNC: number;
  70328. readonly TEXTURE_COMPARE_MODE: number;
  70329. readonly COMPARE_REF_TO_TEXTURE: number;
  70330. readonly TEXTURE_WRAP_R: number;
  70331. readonly HALF_FLOAT: number;
  70332. readonly RGB8: number;
  70333. readonly RED_INTEGER: number;
  70334. readonly RG_INTEGER: number;
  70335. readonly RGB_INTEGER: number;
  70336. readonly RGBA_INTEGER: number;
  70337. readonly R8_SNORM: number;
  70338. readonly RG8_SNORM: number;
  70339. readonly RGB8_SNORM: number;
  70340. readonly RGBA8_SNORM: number;
  70341. readonly R8I: number;
  70342. readonly RG8I: number;
  70343. readonly RGB8I: number;
  70344. readonly RGBA8I: number;
  70345. readonly R8UI: number;
  70346. readonly RG8UI: number;
  70347. readonly RGB8UI: number;
  70348. readonly RGBA8UI: number;
  70349. readonly R16I: number;
  70350. readonly RG16I: number;
  70351. readonly RGB16I: number;
  70352. readonly RGBA16I: number;
  70353. readonly R16UI: number;
  70354. readonly RG16UI: number;
  70355. readonly RGB16UI: number;
  70356. readonly RGBA16UI: number;
  70357. readonly R32I: number;
  70358. readonly RG32I: number;
  70359. readonly RGB32I: number;
  70360. readonly RGBA32I: number;
  70361. readonly R32UI: number;
  70362. readonly RG32UI: number;
  70363. readonly RGB32UI: number;
  70364. readonly RGBA32UI: number;
  70365. readonly RGB10_A2UI: number;
  70366. readonly R11F_G11F_B10F: number;
  70367. readonly RGB9_E5: number;
  70368. readonly RGB10_A2: number;
  70369. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70370. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70371. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70372. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70373. readonly DEPTH_COMPONENT32F: number;
  70374. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70375. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70376. 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;
  70377. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70378. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70379. readonly TRANSFORM_FEEDBACK: number;
  70380. readonly INTERLEAVED_ATTRIBS: number;
  70381. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70382. createTransformFeedback(): WebGLTransformFeedback;
  70383. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70384. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70385. beginTransformFeedback(primitiveMode: number): void;
  70386. endTransformFeedback(): void;
  70387. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70388. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70389. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70390. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70391. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70392. }
  70393. interface ImageBitmap {
  70394. readonly width: number;
  70395. readonly height: number;
  70396. close(): void;
  70397. }
  70398. interface WebGLQuery extends WebGLObject {
  70399. }
  70400. declare var WebGLQuery: {
  70401. prototype: WebGLQuery;
  70402. new(): WebGLQuery;
  70403. };
  70404. interface WebGLSampler extends WebGLObject {
  70405. }
  70406. declare var WebGLSampler: {
  70407. prototype: WebGLSampler;
  70408. new(): WebGLSampler;
  70409. };
  70410. interface WebGLSync extends WebGLObject {
  70411. }
  70412. declare var WebGLSync: {
  70413. prototype: WebGLSync;
  70414. new(): WebGLSync;
  70415. };
  70416. interface WebGLTransformFeedback extends WebGLObject {
  70417. }
  70418. declare var WebGLTransformFeedback: {
  70419. prototype: WebGLTransformFeedback;
  70420. new(): WebGLTransformFeedback;
  70421. };
  70422. interface WebGLVertexArrayObject extends WebGLObject {
  70423. }
  70424. declare var WebGLVertexArrayObject: {
  70425. prototype: WebGLVertexArrayObject;
  70426. new(): WebGLVertexArrayObject;
  70427. };
  70428. // Type definitions for WebVR API
  70429. // Project: https://w3c.github.io/webvr/
  70430. // Definitions by: six a <https://github.com/lostfictions>
  70431. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70432. interface VRDisplay extends EventTarget {
  70433. /**
  70434. * Dictionary of capabilities describing the VRDisplay.
  70435. */
  70436. readonly capabilities: VRDisplayCapabilities;
  70437. /**
  70438. * z-depth defining the far plane of the eye view frustum
  70439. * enables mapping of values in the render target depth
  70440. * attachment to scene coordinates. Initially set to 10000.0.
  70441. */
  70442. depthFar: number;
  70443. /**
  70444. * z-depth defining the near plane of the eye view frustum
  70445. * enables mapping of values in the render target depth
  70446. * attachment to scene coordinates. Initially set to 0.01.
  70447. */
  70448. depthNear: number;
  70449. /**
  70450. * An identifier for this distinct VRDisplay. Used as an
  70451. * association point in the Gamepad API.
  70452. */
  70453. readonly displayId: number;
  70454. /**
  70455. * A display name, a user-readable name identifying it.
  70456. */
  70457. readonly displayName: string;
  70458. readonly isConnected: boolean;
  70459. readonly isPresenting: boolean;
  70460. /**
  70461. * If this VRDisplay supports room-scale experiences, the optional
  70462. * stage attribute contains details on the room-scale parameters.
  70463. */
  70464. readonly stageParameters: VRStageParameters | null;
  70465. /**
  70466. * Passing the value returned by `requestAnimationFrame` to
  70467. * `cancelAnimationFrame` will unregister the callback.
  70468. * @param handle Define the hanle of the request to cancel
  70469. */
  70470. cancelAnimationFrame(handle: number): void;
  70471. /**
  70472. * Stops presenting to the VRDisplay.
  70473. * @returns a promise to know when it stopped
  70474. */
  70475. exitPresent(): Promise<void>;
  70476. /**
  70477. * Return the current VREyeParameters for the given eye.
  70478. * @param whichEye Define the eye we want the parameter for
  70479. * @returns the eye parameters
  70480. */
  70481. getEyeParameters(whichEye: string): VREyeParameters;
  70482. /**
  70483. * Populates the passed VRFrameData with the information required to render
  70484. * the current frame.
  70485. * @param frameData Define the data structure to populate
  70486. * @returns true if ok otherwise false
  70487. */
  70488. getFrameData(frameData: VRFrameData): boolean;
  70489. /**
  70490. * Get the layers currently being presented.
  70491. * @returns the list of VR layers
  70492. */
  70493. getLayers(): VRLayer[];
  70494. /**
  70495. * Return a VRPose containing the future predicted pose of the VRDisplay
  70496. * when the current frame will be presented. The value returned will not
  70497. * change until JavaScript has returned control to the browser.
  70498. *
  70499. * The VRPose will contain the position, orientation, velocity,
  70500. * and acceleration of each of these properties.
  70501. * @returns the pose object
  70502. */
  70503. getPose(): VRPose;
  70504. /**
  70505. * Return the current instantaneous pose of the VRDisplay, with no
  70506. * prediction applied.
  70507. * @returns the current instantaneous pose
  70508. */
  70509. getImmediatePose(): VRPose;
  70510. /**
  70511. * The callback passed to `requestAnimationFrame` will be called
  70512. * any time a new frame should be rendered. When the VRDisplay is
  70513. * presenting the callback will be called at the native refresh
  70514. * rate of the HMD. When not presenting this function acts
  70515. * identically to how window.requestAnimationFrame acts. Content should
  70516. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70517. * asynchronously from other displays and at differing refresh rates.
  70518. * @param callback Define the eaction to run next frame
  70519. * @returns the request handle it
  70520. */
  70521. requestAnimationFrame(callback: FrameRequestCallback): number;
  70522. /**
  70523. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70524. * Repeat calls while already presenting will update the VRLayers being displayed.
  70525. * @param layers Define the list of layer to present
  70526. * @returns a promise to know when the request has been fulfilled
  70527. */
  70528. requestPresent(layers: VRLayer[]): Promise<void>;
  70529. /**
  70530. * Reset the pose for this display, treating its current position and
  70531. * orientation as the "origin/zero" values. VRPose.position,
  70532. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70533. * updated when calling resetPose(). This should be called in only
  70534. * sitting-space experiences.
  70535. */
  70536. resetPose(): void;
  70537. /**
  70538. * The VRLayer provided to the VRDisplay will be captured and presented
  70539. * in the HMD. Calling this function has the same effect on the source
  70540. * canvas as any other operation that uses its source image, and canvases
  70541. * created without preserveDrawingBuffer set to true will be cleared.
  70542. * @param pose Define the pose to submit
  70543. */
  70544. submitFrame(pose?: VRPose): void;
  70545. }
  70546. declare var VRDisplay: {
  70547. prototype: VRDisplay;
  70548. new(): VRDisplay;
  70549. };
  70550. interface VRLayer {
  70551. leftBounds?: number[] | Float32Array | null;
  70552. rightBounds?: number[] | Float32Array | null;
  70553. source?: HTMLCanvasElement | null;
  70554. }
  70555. interface VRDisplayCapabilities {
  70556. readonly canPresent: boolean;
  70557. readonly hasExternalDisplay: boolean;
  70558. readonly hasOrientation: boolean;
  70559. readonly hasPosition: boolean;
  70560. readonly maxLayers: number;
  70561. }
  70562. interface VREyeParameters {
  70563. /** @deprecated */
  70564. readonly fieldOfView: VRFieldOfView;
  70565. readonly offset: Float32Array;
  70566. readonly renderHeight: number;
  70567. readonly renderWidth: number;
  70568. }
  70569. interface VRFieldOfView {
  70570. readonly downDegrees: number;
  70571. readonly leftDegrees: number;
  70572. readonly rightDegrees: number;
  70573. readonly upDegrees: number;
  70574. }
  70575. interface VRFrameData {
  70576. readonly leftProjectionMatrix: Float32Array;
  70577. readonly leftViewMatrix: Float32Array;
  70578. readonly pose: VRPose;
  70579. readonly rightProjectionMatrix: Float32Array;
  70580. readonly rightViewMatrix: Float32Array;
  70581. readonly timestamp: number;
  70582. }
  70583. interface VRPose {
  70584. readonly angularAcceleration: Float32Array | null;
  70585. readonly angularVelocity: Float32Array | null;
  70586. readonly linearAcceleration: Float32Array | null;
  70587. readonly linearVelocity: Float32Array | null;
  70588. readonly orientation: Float32Array | null;
  70589. readonly position: Float32Array | null;
  70590. readonly timestamp: number;
  70591. }
  70592. interface VRStageParameters {
  70593. sittingToStandingTransform?: Float32Array;
  70594. sizeX?: number;
  70595. sizeY?: number;
  70596. }
  70597. interface Navigator {
  70598. getVRDisplays(): Promise<VRDisplay[]>;
  70599. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70600. }
  70601. interface Window {
  70602. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70603. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70604. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70605. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70606. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70607. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70608. }
  70609. interface Gamepad {
  70610. readonly displayId: number;
  70611. }
  70612. type XRSessionMode =
  70613. | "inline"
  70614. | "immersive-vr"
  70615. | "immersive-ar";
  70616. type XRReferenceSpaceType =
  70617. | "viewer"
  70618. | "local"
  70619. | "local-floor"
  70620. | "bounded-floor"
  70621. | "unbounded";
  70622. type XREnvironmentBlendMode =
  70623. | "opaque"
  70624. | "additive"
  70625. | "alpha-blend";
  70626. type XRVisibilityState =
  70627. | "visible"
  70628. | "visible-blurred"
  70629. | "hidden";
  70630. type XRHandedness =
  70631. | "none"
  70632. | "left"
  70633. | "right";
  70634. type XRTargetRayMode =
  70635. | "gaze"
  70636. | "tracked-pointer"
  70637. | "screen";
  70638. type XREye =
  70639. | "none"
  70640. | "left"
  70641. | "right";
  70642. interface XRSpace extends EventTarget {
  70643. }
  70644. interface XRRenderState {
  70645. depthNear?: number;
  70646. depthFar?: number;
  70647. inlineVerticalFieldOfView?: number;
  70648. baseLayer?: XRWebGLLayer;
  70649. }
  70650. interface XRInputSource {
  70651. handedness: XRHandedness;
  70652. targetRayMode: XRTargetRayMode;
  70653. targetRaySpace: XRSpace;
  70654. gripSpace: XRSpace | undefined;
  70655. gamepad: Gamepad | undefined;
  70656. profiles: Array<string>;
  70657. }
  70658. interface XRSessionInit {
  70659. optionalFeatures?: XRReferenceSpaceType[];
  70660. requiredFeatures?: XRReferenceSpaceType[];
  70661. }
  70662. interface XRSession extends XRAnchorCreator {
  70663. addEventListener: Function;
  70664. removeEventListener: Function;
  70665. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70666. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70667. requestAnimationFrame: Function;
  70668. end(): Promise<void>;
  70669. renderState: XRRenderState;
  70670. inputSources: Array<XRInputSource>;
  70671. // hit test
  70672. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70673. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70674. // legacy AR hit test
  70675. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70676. // legacy plane detection
  70677. updateWorldTrackingState(options: {
  70678. planeDetectionState?: { enabled: boolean; }
  70679. }): void;
  70680. }
  70681. interface XRReferenceSpace extends XRSpace {
  70682. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70683. onreset: any;
  70684. }
  70685. type XRPlaneSet = Set<XRPlane>;
  70686. type XRAnchorSet = Set<XRAnchor>;
  70687. interface XRFrame {
  70688. session: XRSession;
  70689. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70690. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70691. // AR
  70692. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70693. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70694. // Anchors
  70695. trackedAnchors?: XRAnchorSet;
  70696. // Planes
  70697. worldInformation: {
  70698. detectedPlanes?: XRPlaneSet;
  70699. };
  70700. }
  70701. interface XRViewerPose extends XRPose {
  70702. views: Array<XRView>;
  70703. }
  70704. interface XRPose {
  70705. transform: XRRigidTransform;
  70706. emulatedPosition: boolean;
  70707. }
  70708. interface XRWebGLLayerOptions {
  70709. antialias?: boolean;
  70710. depth?: boolean;
  70711. stencil?: boolean;
  70712. alpha?: boolean;
  70713. multiview?: boolean;
  70714. framebufferScaleFactor?: number;
  70715. }
  70716. declare var XRWebGLLayer: {
  70717. prototype: XRWebGLLayer;
  70718. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70719. };
  70720. interface XRWebGLLayer {
  70721. framebuffer: WebGLFramebuffer;
  70722. framebufferWidth: number;
  70723. framebufferHeight: number;
  70724. getViewport: Function;
  70725. }
  70726. declare class XRRigidTransform {
  70727. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70728. position: DOMPointReadOnly;
  70729. orientation: DOMPointReadOnly;
  70730. matrix: Float32Array;
  70731. inverse: XRRigidTransform;
  70732. }
  70733. interface XRView {
  70734. eye: XREye;
  70735. projectionMatrix: Float32Array;
  70736. transform: XRRigidTransform;
  70737. }
  70738. interface XRInputSourceChangeEvent {
  70739. session: XRSession;
  70740. removed: Array<XRInputSource>;
  70741. added: Array<XRInputSource>;
  70742. }
  70743. interface XRInputSourceEvent extends Event {
  70744. readonly frame: XRFrame;
  70745. readonly inputSource: XRInputSource;
  70746. }
  70747. // Experimental(er) features
  70748. declare class XRRay {
  70749. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70750. origin: DOMPointReadOnly;
  70751. direction: DOMPointReadOnly;
  70752. matrix: Float32Array;
  70753. }
  70754. declare enum XRHitTestTrackableType {
  70755. "point",
  70756. "plane"
  70757. }
  70758. interface XRHitResult {
  70759. hitMatrix: Float32Array;
  70760. }
  70761. interface XRTransientInputHitTestResult {
  70762. readonly inputSource: XRInputSource;
  70763. readonly results: Array<XRHitTestResult>;
  70764. }
  70765. interface XRHitTestResult {
  70766. getPose(baseSpace: XRSpace): XRPose | undefined;
  70767. }
  70768. interface XRHitTestSource {
  70769. cancel(): void;
  70770. }
  70771. interface XRTransientInputHitTestSource {
  70772. cancel(): void;
  70773. }
  70774. interface XRHitTestOptionsInit {
  70775. space: XRSpace;
  70776. entityTypes?: Array<XRHitTestTrackableType>;
  70777. offsetRay?: XRRay;
  70778. }
  70779. interface XRTransientInputHitTestOptionsInit {
  70780. profile: string;
  70781. entityTypes?: Array<XRHitTestTrackableType>;
  70782. offsetRay?: XRRay;
  70783. }
  70784. interface XRAnchor {
  70785. // remove?
  70786. id?: string;
  70787. anchorSpace: XRSpace;
  70788. lastChangedTime: number;
  70789. detach(): void;
  70790. }
  70791. interface XRPlane extends XRAnchorCreator {
  70792. orientation: "Horizontal" | "Vertical";
  70793. planeSpace: XRSpace;
  70794. polygon: Array<DOMPointReadOnly>;
  70795. lastChangedTime: number;
  70796. }
  70797. interface XRAnchorCreator {
  70798. // AR Anchors
  70799. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70800. }
  70801. /**
  70802. * @ignore
  70803. */
  70804. declare module BABYLON.GLTF2.Exporter {
  70805. }
  70806. /**
  70807. * @ignore
  70808. */
  70809. declare module BABYLON.GLTF1 {
  70810. }
  70811. declare module BABYLON.GUI {
  70812. /**
  70813. * Class used to specific a value and its associated unit
  70814. */
  70815. export class ValueAndUnit {
  70816. /** defines the unit to store */
  70817. unit: number;
  70818. /** defines a boolean indicating if the value can be negative */
  70819. negativeValueAllowed: boolean;
  70820. private _value;
  70821. private _originalUnit;
  70822. /**
  70823. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70824. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70825. */
  70826. ignoreAdaptiveScaling: boolean;
  70827. /**
  70828. * Creates a new ValueAndUnit
  70829. * @param value defines the value to store
  70830. * @param unit defines the unit to store
  70831. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70832. */
  70833. constructor(value: number,
  70834. /** defines the unit to store */
  70835. unit?: number,
  70836. /** defines a boolean indicating if the value can be negative */
  70837. negativeValueAllowed?: boolean);
  70838. /** Gets a boolean indicating if the value is a percentage */
  70839. get isPercentage(): boolean;
  70840. /** Gets a boolean indicating if the value is store as pixel */
  70841. get isPixel(): boolean;
  70842. /** Gets direct internal value */
  70843. get internalValue(): number;
  70844. /**
  70845. * Gets value as pixel
  70846. * @param host defines the root host
  70847. * @param refValue defines the reference value for percentages
  70848. * @returns the value as pixel
  70849. */
  70850. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70851. /**
  70852. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70853. * @param value defines the value to store
  70854. * @param unit defines the unit to store
  70855. * @returns the current ValueAndUnit
  70856. */
  70857. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70858. /**
  70859. * Gets the value accordingly to its unit
  70860. * @param host defines the root host
  70861. * @returns the value
  70862. */
  70863. getValue(host: AdvancedDynamicTexture): number;
  70864. /**
  70865. * Gets a string representation of the value
  70866. * @param host defines the root host
  70867. * @param decimals defines an optional number of decimals to display
  70868. * @returns a string
  70869. */
  70870. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70871. /**
  70872. * Store a value parsed from a string
  70873. * @param source defines the source string
  70874. * @returns true if the value was successfully parsed
  70875. */
  70876. fromString(source: string | number): boolean;
  70877. private static _Regex;
  70878. private static _UNITMODE_PERCENTAGE;
  70879. private static _UNITMODE_PIXEL;
  70880. /** UNITMODE_PERCENTAGE */
  70881. static get UNITMODE_PERCENTAGE(): number;
  70882. /** UNITMODE_PIXEL */
  70883. static get UNITMODE_PIXEL(): number;
  70884. }
  70885. }
  70886. declare module BABYLON.GUI {
  70887. /**
  70888. * Define a style used by control to automatically setup properties based on a template.
  70889. * Only support font related properties so far
  70890. */
  70891. export class Style implements BABYLON.IDisposable {
  70892. private _fontFamily;
  70893. private _fontStyle;
  70894. private _fontWeight;
  70895. /** @hidden */
  70896. _host: AdvancedDynamicTexture;
  70897. /** @hidden */
  70898. _fontSize: ValueAndUnit;
  70899. /**
  70900. * BABYLON.Observable raised when the style values are changed
  70901. */
  70902. onChangedObservable: BABYLON.Observable<Style>;
  70903. /**
  70904. * Creates a new style object
  70905. * @param host defines the AdvancedDynamicTexture which hosts this style
  70906. */
  70907. constructor(host: AdvancedDynamicTexture);
  70908. /**
  70909. * Gets or sets the font size
  70910. */
  70911. get fontSize(): string | number;
  70912. set fontSize(value: string | number);
  70913. /**
  70914. * Gets or sets the font family
  70915. */
  70916. get fontFamily(): string;
  70917. set fontFamily(value: string);
  70918. /**
  70919. * Gets or sets the font style
  70920. */
  70921. get fontStyle(): string;
  70922. set fontStyle(value: string);
  70923. /** Gets or sets font weight */
  70924. get fontWeight(): string;
  70925. set fontWeight(value: string);
  70926. /** Dispose all associated resources */
  70927. dispose(): void;
  70928. }
  70929. }
  70930. declare module BABYLON.GUI {
  70931. /**
  70932. * Class used to transport BABYLON.Vector2 information for pointer events
  70933. */
  70934. export class Vector2WithInfo extends BABYLON.Vector2 {
  70935. /** defines the current mouse button index */
  70936. buttonIndex: number;
  70937. /**
  70938. * Creates a new Vector2WithInfo
  70939. * @param source defines the vector2 data to transport
  70940. * @param buttonIndex defines the current mouse button index
  70941. */
  70942. constructor(source: BABYLON.Vector2,
  70943. /** defines the current mouse button index */
  70944. buttonIndex?: number);
  70945. }
  70946. /** Class used to provide 2D matrix features */
  70947. export class Matrix2D {
  70948. /** Gets the internal array of 6 floats used to store matrix data */
  70949. m: Float32Array;
  70950. /**
  70951. * Creates a new matrix
  70952. * @param m00 defines value for (0, 0)
  70953. * @param m01 defines value for (0, 1)
  70954. * @param m10 defines value for (1, 0)
  70955. * @param m11 defines value for (1, 1)
  70956. * @param m20 defines value for (2, 0)
  70957. * @param m21 defines value for (2, 1)
  70958. */
  70959. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70960. /**
  70961. * Fills the matrix from direct values
  70962. * @param m00 defines value for (0, 0)
  70963. * @param m01 defines value for (0, 1)
  70964. * @param m10 defines value for (1, 0)
  70965. * @param m11 defines value for (1, 1)
  70966. * @param m20 defines value for (2, 0)
  70967. * @param m21 defines value for (2, 1)
  70968. * @returns the current modified matrix
  70969. */
  70970. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70971. /**
  70972. * Gets matrix determinant
  70973. * @returns the determinant
  70974. */
  70975. determinant(): number;
  70976. /**
  70977. * Inverses the matrix and stores it in a target matrix
  70978. * @param result defines the target matrix
  70979. * @returns the current matrix
  70980. */
  70981. invertToRef(result: Matrix2D): Matrix2D;
  70982. /**
  70983. * Multiplies the current matrix with another one
  70984. * @param other defines the second operand
  70985. * @param result defines the target matrix
  70986. * @returns the current matrix
  70987. */
  70988. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70989. /**
  70990. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70991. * @param x defines the x coordinate to transform
  70992. * @param y defines the x coordinate to transform
  70993. * @param result defines the target vector2
  70994. * @returns the current matrix
  70995. */
  70996. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70997. /**
  70998. * Creates an identity matrix
  70999. * @returns a new matrix
  71000. */
  71001. static Identity(): Matrix2D;
  71002. /**
  71003. * Creates a translation matrix and stores it in a target matrix
  71004. * @param x defines the x coordinate of the translation
  71005. * @param y defines the y coordinate of the translation
  71006. * @param result defines the target matrix
  71007. */
  71008. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71009. /**
  71010. * Creates a scaling matrix and stores it in a target matrix
  71011. * @param x defines the x coordinate of the scaling
  71012. * @param y defines the y coordinate of the scaling
  71013. * @param result defines the target matrix
  71014. */
  71015. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71016. /**
  71017. * Creates a rotation matrix and stores it in a target matrix
  71018. * @param angle defines the rotation angle
  71019. * @param result defines the target matrix
  71020. */
  71021. static RotationToRef(angle: number, result: Matrix2D): void;
  71022. private static _TempPreTranslationMatrix;
  71023. private static _TempPostTranslationMatrix;
  71024. private static _TempRotationMatrix;
  71025. private static _TempScalingMatrix;
  71026. private static _TempCompose0;
  71027. private static _TempCompose1;
  71028. private static _TempCompose2;
  71029. /**
  71030. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71031. * @param tx defines the x coordinate of the translation
  71032. * @param ty defines the y coordinate of the translation
  71033. * @param angle defines the rotation angle
  71034. * @param scaleX defines the x coordinate of the scaling
  71035. * @param scaleY defines the y coordinate of the scaling
  71036. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71037. * @param result defines the target matrix
  71038. */
  71039. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71040. }
  71041. }
  71042. declare module BABYLON.GUI {
  71043. /**
  71044. * Class used to store 2D control sizes
  71045. */
  71046. export class Measure {
  71047. /** defines left coordinate */
  71048. left: number;
  71049. /** defines top coordinate */
  71050. top: number;
  71051. /** defines width dimension */
  71052. width: number;
  71053. /** defines height dimension */
  71054. height: number;
  71055. /**
  71056. * Creates a new measure
  71057. * @param left defines left coordinate
  71058. * @param top defines top coordinate
  71059. * @param width defines width dimension
  71060. * @param height defines height dimension
  71061. */
  71062. constructor(
  71063. /** defines left coordinate */
  71064. left: number,
  71065. /** defines top coordinate */
  71066. top: number,
  71067. /** defines width dimension */
  71068. width: number,
  71069. /** defines height dimension */
  71070. height: number);
  71071. /**
  71072. * Copy from another measure
  71073. * @param other defines the other measure to copy from
  71074. */
  71075. copyFrom(other: Measure): void;
  71076. /**
  71077. * Copy from a group of 4 floats
  71078. * @param left defines left coordinate
  71079. * @param top defines top coordinate
  71080. * @param width defines width dimension
  71081. * @param height defines height dimension
  71082. */
  71083. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71084. /**
  71085. * Computes the axis aligned bounding box measure for two given measures
  71086. * @param a Input measure
  71087. * @param b Input measure
  71088. * @param result the resulting bounding measure
  71089. */
  71090. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71091. /**
  71092. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71093. * @param transform the matrix to transform the measure before computing the AABB
  71094. * @param result the resulting AABB
  71095. */
  71096. transformToRef(transform: Matrix2D, result: Measure): void;
  71097. /**
  71098. * Check equality between this measure and another one
  71099. * @param other defines the other measures
  71100. * @returns true if both measures are equals
  71101. */
  71102. isEqualsTo(other: Measure): boolean;
  71103. /**
  71104. * Creates an empty measure
  71105. * @returns a new measure
  71106. */
  71107. static Empty(): Measure;
  71108. }
  71109. }
  71110. declare module BABYLON.GUI {
  71111. /**
  71112. * Interface used to define a control that can receive focus
  71113. */
  71114. export interface IFocusableControl {
  71115. /**
  71116. * Function called when the control receives the focus
  71117. */
  71118. onFocus(): void;
  71119. /**
  71120. * Function called when the control loses the focus
  71121. */
  71122. onBlur(): void;
  71123. /**
  71124. * Function called to let the control handle keyboard events
  71125. * @param evt defines the current keyboard event
  71126. */
  71127. processKeyboard(evt: KeyboardEvent): void;
  71128. /**
  71129. * Function called to get the list of controls that should not steal the focus from this control
  71130. * @returns an array of controls
  71131. */
  71132. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71133. }
  71134. /**
  71135. * Class used to create texture to support 2D GUI elements
  71136. * @see http://doc.babylonjs.com/how_to/gui
  71137. */
  71138. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71139. private _isDirty;
  71140. private _renderObserver;
  71141. private _resizeObserver;
  71142. private _preKeyboardObserver;
  71143. private _pointerMoveObserver;
  71144. private _pointerObserver;
  71145. private _canvasPointerOutObserver;
  71146. private _background;
  71147. /** @hidden */
  71148. _rootContainer: Container;
  71149. /** @hidden */
  71150. _lastPickedControl: Control;
  71151. /** @hidden */
  71152. _lastControlOver: {
  71153. [pointerId: number]: Control;
  71154. };
  71155. /** @hidden */
  71156. _lastControlDown: {
  71157. [pointerId: number]: Control;
  71158. };
  71159. /** @hidden */
  71160. _capturingControl: {
  71161. [pointerId: number]: Control;
  71162. };
  71163. /** @hidden */
  71164. _shouldBlockPointer: boolean;
  71165. /** @hidden */
  71166. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71167. /** @hidden */
  71168. _linkedControls: Control[];
  71169. private _isFullscreen;
  71170. private _fullscreenViewport;
  71171. private _idealWidth;
  71172. private _idealHeight;
  71173. private _useSmallestIdeal;
  71174. private _renderAtIdealSize;
  71175. private _focusedControl;
  71176. private _blockNextFocusCheck;
  71177. private _renderScale;
  71178. private _rootElement;
  71179. private _cursorChanged;
  71180. private _defaultMousePointerId;
  71181. /** @hidden */
  71182. _numLayoutCalls: number;
  71183. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71184. get numLayoutCalls(): number;
  71185. /** @hidden */
  71186. _numRenderCalls: number;
  71187. /** Gets the number of render calls made the last time the ADT has been rendered */
  71188. get numRenderCalls(): number;
  71189. /**
  71190. * Define type to string to ensure compatibility across browsers
  71191. * Safari doesn't support DataTransfer constructor
  71192. */
  71193. private _clipboardData;
  71194. /**
  71195. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71196. */
  71197. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71198. /**
  71199. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71200. */
  71201. onControlPickedObservable: BABYLON.Observable<Control>;
  71202. /**
  71203. * BABYLON.Observable event triggered before layout is evaluated
  71204. */
  71205. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71206. /**
  71207. * BABYLON.Observable event triggered after the layout was evaluated
  71208. */
  71209. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71210. /**
  71211. * BABYLON.Observable event triggered before the texture is rendered
  71212. */
  71213. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71214. /**
  71215. * BABYLON.Observable event triggered after the texture was rendered
  71216. */
  71217. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71218. /**
  71219. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71220. */
  71221. premulAlpha: boolean;
  71222. /**
  71223. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71224. * Useful when you want more antialiasing
  71225. */
  71226. get renderScale(): number;
  71227. set renderScale(value: number);
  71228. /** Gets or sets the background color */
  71229. get background(): string;
  71230. set background(value: string);
  71231. /**
  71232. * Gets or sets the ideal width used to design controls.
  71233. * The GUI will then rescale everything accordingly
  71234. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71235. */
  71236. get idealWidth(): number;
  71237. set idealWidth(value: number);
  71238. /**
  71239. * Gets or sets the ideal height used to design controls.
  71240. * The GUI will then rescale everything accordingly
  71241. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71242. */
  71243. get idealHeight(): number;
  71244. set idealHeight(value: number);
  71245. /**
  71246. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71247. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71248. */
  71249. get useSmallestIdeal(): boolean;
  71250. set useSmallestIdeal(value: boolean);
  71251. /**
  71252. * Gets or sets a boolean indicating if adaptive scaling must be used
  71253. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71254. */
  71255. get renderAtIdealSize(): boolean;
  71256. set renderAtIdealSize(value: boolean);
  71257. /**
  71258. * Gets the ratio used when in "ideal mode"
  71259. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71260. * */
  71261. get idealRatio(): number;
  71262. /**
  71263. * Gets the underlying layer used to render the texture when in fullscreen mode
  71264. */
  71265. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71266. /**
  71267. * Gets the root container control
  71268. */
  71269. get rootContainer(): Container;
  71270. /**
  71271. * Returns an array containing the root container.
  71272. * This is mostly used to let the Inspector introspects the ADT
  71273. * @returns an array containing the rootContainer
  71274. */
  71275. getChildren(): Array<Container>;
  71276. /**
  71277. * Will return all controls that are inside this texture
  71278. * @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
  71279. * @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
  71280. * @return all child controls
  71281. */
  71282. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71283. /**
  71284. * Gets or sets the current focused control
  71285. */
  71286. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71287. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71288. /**
  71289. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71290. */
  71291. get isForeground(): boolean;
  71292. set isForeground(value: boolean);
  71293. /**
  71294. * Gets or set information about clipboardData
  71295. */
  71296. get clipboardData(): string;
  71297. set clipboardData(value: string);
  71298. /**
  71299. * Creates a new AdvancedDynamicTexture
  71300. * @param name defines the name of the texture
  71301. * @param width defines the width of the texture
  71302. * @param height defines the height of the texture
  71303. * @param scene defines the hosting scene
  71304. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71305. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71306. */
  71307. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71308. /**
  71309. * Get the current class name of the texture useful for serialization or dynamic coding.
  71310. * @returns "AdvancedDynamicTexture"
  71311. */
  71312. getClassName(): string;
  71313. /**
  71314. * Function used to execute a function on all controls
  71315. * @param func defines the function to execute
  71316. * @param container defines the container where controls belong. If null the root container will be used
  71317. */
  71318. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71319. private _useInvalidateRectOptimization;
  71320. /**
  71321. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71322. */
  71323. get useInvalidateRectOptimization(): boolean;
  71324. set useInvalidateRectOptimization(value: boolean);
  71325. private _invalidatedRectangle;
  71326. /**
  71327. * Invalidates a rectangle area on the gui texture
  71328. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71329. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71330. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71331. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71332. */
  71333. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71334. /**
  71335. * Marks the texture as dirty forcing a complete update
  71336. */
  71337. markAsDirty(): void;
  71338. /**
  71339. * Helper function used to create a new style
  71340. * @returns a new style
  71341. * @see http://doc.babylonjs.com/how_to/gui#styles
  71342. */
  71343. createStyle(): Style;
  71344. /**
  71345. * Adds a new control to the root container
  71346. * @param control defines the control to add
  71347. * @returns the current texture
  71348. */
  71349. addControl(control: Control): AdvancedDynamicTexture;
  71350. /**
  71351. * Removes a control from the root container
  71352. * @param control defines the control to remove
  71353. * @returns the current texture
  71354. */
  71355. removeControl(control: Control): AdvancedDynamicTexture;
  71356. /**
  71357. * Release all resources
  71358. */
  71359. dispose(): void;
  71360. private _onResize;
  71361. /** @hidden */
  71362. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71363. /**
  71364. * Get screen coordinates for a vector3
  71365. * @param position defines the position to project
  71366. * @param worldMatrix defines the world matrix to use
  71367. * @returns the projected position
  71368. */
  71369. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71370. private _checkUpdate;
  71371. private _clearMeasure;
  71372. private _render;
  71373. /** @hidden */
  71374. _changeCursor(cursor: string): void;
  71375. /** @hidden */
  71376. _registerLastControlDown(control: Control, pointerId: number): void;
  71377. private _doPicking;
  71378. /** @hidden */
  71379. _cleanControlAfterRemovalFromList(list: {
  71380. [pointerId: number]: Control;
  71381. }, control: Control): void;
  71382. /** @hidden */
  71383. _cleanControlAfterRemoval(control: Control): void;
  71384. /** Attach to all scene events required to support pointer events */
  71385. attach(): void;
  71386. /** @hidden */
  71387. private onClipboardCopy;
  71388. /** @hidden */
  71389. private onClipboardCut;
  71390. /** @hidden */
  71391. private onClipboardPaste;
  71392. /**
  71393. * Register the clipboard Events onto the canvas
  71394. */
  71395. registerClipboardEvents(): void;
  71396. /**
  71397. * Unregister the clipboard Events from the canvas
  71398. */
  71399. unRegisterClipboardEvents(): void;
  71400. /**
  71401. * Connect the texture to a hosting mesh to enable interactions
  71402. * @param mesh defines the mesh to attach to
  71403. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71404. */
  71405. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71406. /**
  71407. * Move the focus to a specific control
  71408. * @param control defines the control which will receive the focus
  71409. */
  71410. moveFocusToControl(control: IFocusableControl): void;
  71411. private _manageFocus;
  71412. private _attachToOnPointerOut;
  71413. /**
  71414. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71415. * @param mesh defines the mesh which will receive the texture
  71416. * @param width defines the texture width (1024 by default)
  71417. * @param height defines the texture height (1024 by default)
  71418. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71419. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71420. * @returns a new AdvancedDynamicTexture
  71421. */
  71422. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71423. /**
  71424. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71425. * In this mode the texture will rely on a layer for its rendering.
  71426. * This allows it to be treated like any other layer.
  71427. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71428. * LayerMask is set through advancedTexture.layer.layerMask
  71429. * @param name defines name for the texture
  71430. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71431. * @param scene defines the hsoting scene
  71432. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71433. * @returns a new AdvancedDynamicTexture
  71434. */
  71435. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71436. }
  71437. }
  71438. declare module BABYLON.GUI {
  71439. /**
  71440. * Root class used for all 2D controls
  71441. * @see http://doc.babylonjs.com/how_to/gui#controls
  71442. */
  71443. export class Control {
  71444. /** defines the name of the control */
  71445. name?: string | undefined;
  71446. /**
  71447. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71448. */
  71449. static AllowAlphaInheritance: boolean;
  71450. private _alpha;
  71451. private _alphaSet;
  71452. private _zIndex;
  71453. /** @hidden */
  71454. _host: AdvancedDynamicTexture;
  71455. /** Gets or sets the control parent */
  71456. parent: BABYLON.Nullable<Container>;
  71457. /** @hidden */
  71458. _currentMeasure: Measure;
  71459. private _fontFamily;
  71460. private _fontStyle;
  71461. private _fontWeight;
  71462. private _fontSize;
  71463. private _font;
  71464. /** @hidden */
  71465. _width: ValueAndUnit;
  71466. /** @hidden */
  71467. _height: ValueAndUnit;
  71468. /** @hidden */
  71469. protected _fontOffset: {
  71470. ascent: number;
  71471. height: number;
  71472. descent: number;
  71473. };
  71474. private _color;
  71475. private _style;
  71476. private _styleObserver;
  71477. /** @hidden */
  71478. protected _horizontalAlignment: number;
  71479. /** @hidden */
  71480. protected _verticalAlignment: number;
  71481. /** @hidden */
  71482. protected _isDirty: boolean;
  71483. /** @hidden */
  71484. protected _wasDirty: boolean;
  71485. /** @hidden */
  71486. _tempParentMeasure: Measure;
  71487. /** @hidden */
  71488. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71489. /** @hidden */
  71490. protected _cachedParentMeasure: Measure;
  71491. private _paddingLeft;
  71492. private _paddingRight;
  71493. private _paddingTop;
  71494. private _paddingBottom;
  71495. /** @hidden */
  71496. _left: ValueAndUnit;
  71497. /** @hidden */
  71498. _top: ValueAndUnit;
  71499. private _scaleX;
  71500. private _scaleY;
  71501. private _rotation;
  71502. private _transformCenterX;
  71503. private _transformCenterY;
  71504. /** @hidden */
  71505. _transformMatrix: Matrix2D;
  71506. /** @hidden */
  71507. protected _invertTransformMatrix: Matrix2D;
  71508. /** @hidden */
  71509. protected _transformedPosition: BABYLON.Vector2;
  71510. private _isMatrixDirty;
  71511. private _cachedOffsetX;
  71512. private _cachedOffsetY;
  71513. private _isVisible;
  71514. private _isHighlighted;
  71515. /** @hidden */
  71516. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71517. private _fontSet;
  71518. private _dummyVector2;
  71519. private _downCount;
  71520. private _enterCount;
  71521. private _doNotRender;
  71522. private _downPointerIds;
  71523. protected _isEnabled: boolean;
  71524. protected _disabledColor: string;
  71525. protected _disabledColorItem: string;
  71526. /** @hidden */
  71527. protected _rebuildLayout: boolean;
  71528. /** @hidden */
  71529. _customData: any;
  71530. /** @hidden */
  71531. _isClipped: boolean;
  71532. /** @hidden */
  71533. _automaticSize: boolean;
  71534. /** @hidden */
  71535. _tag: any;
  71536. /**
  71537. * 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
  71538. */
  71539. uniqueId: number;
  71540. /**
  71541. * Gets or sets an object used to store user defined information for the node
  71542. */
  71543. metadata: any;
  71544. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71545. isHitTestVisible: boolean;
  71546. /** Gets or sets a boolean indicating if the control can block pointer events */
  71547. isPointerBlocker: boolean;
  71548. /** Gets or sets a boolean indicating if the control can be focusable */
  71549. isFocusInvisible: boolean;
  71550. /**
  71551. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71552. * 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
  71553. */
  71554. clipChildren: boolean;
  71555. /**
  71556. * Gets or sets a boolean indicating that control content must be clipped
  71557. * 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
  71558. */
  71559. clipContent: boolean;
  71560. /**
  71561. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71562. */
  71563. useBitmapCache: boolean;
  71564. private _cacheData;
  71565. private _shadowOffsetX;
  71566. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71567. get shadowOffsetX(): number;
  71568. set shadowOffsetX(value: number);
  71569. private _shadowOffsetY;
  71570. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71571. get shadowOffsetY(): number;
  71572. set shadowOffsetY(value: number);
  71573. private _shadowBlur;
  71574. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71575. get shadowBlur(): number;
  71576. set shadowBlur(value: number);
  71577. private _shadowColor;
  71578. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71579. get shadowColor(): string;
  71580. set shadowColor(value: string);
  71581. /** Gets or sets the cursor to use when the control is hovered */
  71582. hoverCursor: string;
  71583. /** @hidden */
  71584. protected _linkOffsetX: ValueAndUnit;
  71585. /** @hidden */
  71586. protected _linkOffsetY: ValueAndUnit;
  71587. /** Gets the control type name */
  71588. get typeName(): string;
  71589. /**
  71590. * Get the current class name of the control.
  71591. * @returns current class name
  71592. */
  71593. getClassName(): string;
  71594. /**
  71595. * An event triggered when pointer wheel is scrolled
  71596. */
  71597. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71598. /**
  71599. * An event triggered when the pointer move over the control.
  71600. */
  71601. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71602. /**
  71603. * An event triggered when the pointer move out of the control.
  71604. */
  71605. onPointerOutObservable: BABYLON.Observable<Control>;
  71606. /**
  71607. * An event triggered when the pointer taps the control
  71608. */
  71609. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71610. /**
  71611. * An event triggered when pointer up
  71612. */
  71613. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71614. /**
  71615. * An event triggered when a control is clicked on
  71616. */
  71617. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71618. /**
  71619. * An event triggered when pointer enters the control
  71620. */
  71621. onPointerEnterObservable: BABYLON.Observable<Control>;
  71622. /**
  71623. * An event triggered when the control is marked as dirty
  71624. */
  71625. onDirtyObservable: BABYLON.Observable<Control>;
  71626. /**
  71627. * An event triggered before drawing the control
  71628. */
  71629. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71630. /**
  71631. * An event triggered after the control was drawn
  71632. */
  71633. onAfterDrawObservable: BABYLON.Observable<Control>;
  71634. /**
  71635. * Get the hosting AdvancedDynamicTexture
  71636. */
  71637. get host(): AdvancedDynamicTexture;
  71638. /** Gets or set information about font offsets (used to render and align text) */
  71639. get fontOffset(): {
  71640. ascent: number;
  71641. height: number;
  71642. descent: number;
  71643. };
  71644. set fontOffset(offset: {
  71645. ascent: number;
  71646. height: number;
  71647. descent: number;
  71648. });
  71649. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71650. get alpha(): number;
  71651. set alpha(value: number);
  71652. /**
  71653. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71654. */
  71655. get isHighlighted(): boolean;
  71656. set isHighlighted(value: boolean);
  71657. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71658. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71659. */
  71660. get scaleX(): number;
  71661. set scaleX(value: number);
  71662. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71663. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71664. */
  71665. get scaleY(): number;
  71666. set scaleY(value: number);
  71667. /** Gets or sets the rotation angle (0 by default)
  71668. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71669. */
  71670. get rotation(): number;
  71671. set rotation(value: number);
  71672. /** Gets or sets the transformation center on Y axis (0 by default)
  71673. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71674. */
  71675. get transformCenterY(): number;
  71676. set transformCenterY(value: number);
  71677. /** Gets or sets the transformation center on X axis (0 by default)
  71678. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71679. */
  71680. get transformCenterX(): number;
  71681. set transformCenterX(value: number);
  71682. /**
  71683. * Gets or sets the horizontal alignment
  71684. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71685. */
  71686. get horizontalAlignment(): number;
  71687. set horizontalAlignment(value: number);
  71688. /**
  71689. * Gets or sets the vertical alignment
  71690. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71691. */
  71692. get verticalAlignment(): number;
  71693. set verticalAlignment(value: number);
  71694. /**
  71695. * Gets or sets control width
  71696. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71697. */
  71698. get width(): string | number;
  71699. set width(value: string | number);
  71700. /**
  71701. * Gets or sets the control width in pixel
  71702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71703. */
  71704. get widthInPixels(): number;
  71705. set widthInPixels(value: number);
  71706. /**
  71707. * Gets or sets control height
  71708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71709. */
  71710. get height(): string | number;
  71711. set height(value: string | number);
  71712. /**
  71713. * Gets or sets control height in pixel
  71714. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71715. */
  71716. get heightInPixels(): number;
  71717. set heightInPixels(value: number);
  71718. /** Gets or set font family */
  71719. get fontFamily(): string;
  71720. set fontFamily(value: string);
  71721. /** Gets or sets font style */
  71722. get fontStyle(): string;
  71723. set fontStyle(value: string);
  71724. /** Gets or sets font weight */
  71725. get fontWeight(): string;
  71726. set fontWeight(value: string);
  71727. /**
  71728. * Gets or sets style
  71729. * @see http://doc.babylonjs.com/how_to/gui#styles
  71730. */
  71731. get style(): BABYLON.Nullable<Style>;
  71732. set style(value: BABYLON.Nullable<Style>);
  71733. /** @hidden */
  71734. get _isFontSizeInPercentage(): boolean;
  71735. /** Gets or sets font size in pixels */
  71736. get fontSizeInPixels(): number;
  71737. set fontSizeInPixels(value: number);
  71738. /** Gets or sets font size */
  71739. get fontSize(): string | number;
  71740. set fontSize(value: string | number);
  71741. /** Gets or sets foreground color */
  71742. get color(): string;
  71743. set color(value: string);
  71744. /** Gets or sets z index which is used to reorder controls on the z axis */
  71745. get zIndex(): number;
  71746. set zIndex(value: number);
  71747. /** Gets or sets a boolean indicating if the control can be rendered */
  71748. get notRenderable(): boolean;
  71749. set notRenderable(value: boolean);
  71750. /** Gets or sets a boolean indicating if the control is visible */
  71751. get isVisible(): boolean;
  71752. set isVisible(value: boolean);
  71753. /** Gets a boolean indicating that the control needs to update its rendering */
  71754. get isDirty(): boolean;
  71755. /**
  71756. * Gets the current linked mesh (or null if none)
  71757. */
  71758. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71759. /**
  71760. * Gets or sets a value indicating the padding to use on the left of the control
  71761. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71762. */
  71763. get paddingLeft(): string | number;
  71764. set paddingLeft(value: string | number);
  71765. /**
  71766. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71767. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71768. */
  71769. get paddingLeftInPixels(): number;
  71770. set paddingLeftInPixels(value: number);
  71771. /**
  71772. * Gets or sets a value indicating the padding to use on the right of the control
  71773. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71774. */
  71775. get paddingRight(): string | number;
  71776. set paddingRight(value: string | number);
  71777. /**
  71778. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71780. */
  71781. get paddingRightInPixels(): number;
  71782. set paddingRightInPixels(value: number);
  71783. /**
  71784. * Gets or sets a value indicating the padding to use on the top of the control
  71785. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71786. */
  71787. get paddingTop(): string | number;
  71788. set paddingTop(value: string | number);
  71789. /**
  71790. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71791. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71792. */
  71793. get paddingTopInPixels(): number;
  71794. set paddingTopInPixels(value: number);
  71795. /**
  71796. * Gets or sets a value indicating the padding to use on the bottom of the control
  71797. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71798. */
  71799. get paddingBottom(): string | number;
  71800. set paddingBottom(value: string | number);
  71801. /**
  71802. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71803. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71804. */
  71805. get paddingBottomInPixels(): number;
  71806. set paddingBottomInPixels(value: number);
  71807. /**
  71808. * Gets or sets a value indicating the left coordinate of the control
  71809. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71810. */
  71811. get left(): string | number;
  71812. set left(value: string | number);
  71813. /**
  71814. * Gets or sets a value indicating the left coordinate in pixels of the control
  71815. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71816. */
  71817. get leftInPixels(): number;
  71818. set leftInPixels(value: number);
  71819. /**
  71820. * Gets or sets a value indicating the top coordinate of the control
  71821. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71822. */
  71823. get top(): string | number;
  71824. set top(value: string | number);
  71825. /**
  71826. * Gets or sets a value indicating the top coordinate in pixels of the control
  71827. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71828. */
  71829. get topInPixels(): number;
  71830. set topInPixels(value: number);
  71831. /**
  71832. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71833. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71834. */
  71835. get linkOffsetX(): string | number;
  71836. set linkOffsetX(value: string | number);
  71837. /**
  71838. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71839. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71840. */
  71841. get linkOffsetXInPixels(): number;
  71842. set linkOffsetXInPixels(value: number);
  71843. /**
  71844. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71845. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71846. */
  71847. get linkOffsetY(): string | number;
  71848. set linkOffsetY(value: string | number);
  71849. /**
  71850. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71851. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71852. */
  71853. get linkOffsetYInPixels(): number;
  71854. set linkOffsetYInPixels(value: number);
  71855. /** Gets the center coordinate on X axis */
  71856. get centerX(): number;
  71857. /** Gets the center coordinate on Y axis */
  71858. get centerY(): number;
  71859. /** Gets or sets if control is Enabled*/
  71860. get isEnabled(): boolean;
  71861. set isEnabled(value: boolean);
  71862. /** Gets or sets background color of control if it's disabled*/
  71863. get disabledColor(): string;
  71864. set disabledColor(value: string);
  71865. /** Gets or sets front color of control if it's disabled*/
  71866. get disabledColorItem(): string;
  71867. set disabledColorItem(value: string);
  71868. /**
  71869. * Creates a new control
  71870. * @param name defines the name of the control
  71871. */
  71872. constructor(
  71873. /** defines the name of the control */
  71874. name?: string | undefined);
  71875. /** @hidden */
  71876. protected _getTypeName(): string;
  71877. /**
  71878. * Gets the first ascendant in the hierarchy of the given type
  71879. * @param className defines the required type
  71880. * @returns the ascendant or null if not found
  71881. */
  71882. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71883. /** @hidden */
  71884. _resetFontCache(): void;
  71885. /**
  71886. * Determines if a container is an ascendant of the current control
  71887. * @param container defines the container to look for
  71888. * @returns true if the container is one of the ascendant of the control
  71889. */
  71890. isAscendant(container: Control): boolean;
  71891. /**
  71892. * Gets coordinates in local control space
  71893. * @param globalCoordinates defines the coordinates to transform
  71894. * @returns the new coordinates in local space
  71895. */
  71896. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71897. /**
  71898. * Gets coordinates in local control space
  71899. * @param globalCoordinates defines the coordinates to transform
  71900. * @param result defines the target vector2 where to store the result
  71901. * @returns the current control
  71902. */
  71903. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71904. /**
  71905. * Gets coordinates in parent local control space
  71906. * @param globalCoordinates defines the coordinates to transform
  71907. * @returns the new coordinates in parent local space
  71908. */
  71909. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71910. /**
  71911. * Move the current control to a vector3 position projected onto the screen.
  71912. * @param position defines the target position
  71913. * @param scene defines the hosting scene
  71914. */
  71915. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71916. /**
  71917. * Will store all controls that have this control as ascendant in a given array
  71918. * @param results defines the array where to store the descendants
  71919. * @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
  71920. * @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
  71921. */
  71922. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71923. /**
  71924. * Will return all controls that have this control as ascendant
  71925. * @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
  71926. * @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
  71927. * @return all child controls
  71928. */
  71929. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71930. /**
  71931. * Link current control with a target mesh
  71932. * @param mesh defines the mesh to link with
  71933. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71934. */
  71935. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71936. /** @hidden */
  71937. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71938. /** @hidden */
  71939. _offsetLeft(offset: number): void;
  71940. /** @hidden */
  71941. _offsetTop(offset: number): void;
  71942. /** @hidden */
  71943. _markMatrixAsDirty(): void;
  71944. /** @hidden */
  71945. _flagDescendantsAsMatrixDirty(): void;
  71946. /** @hidden */
  71947. _intersectsRect(rect: Measure): boolean;
  71948. /** @hidden */
  71949. protected invalidateRect(): void;
  71950. /** @hidden */
  71951. _markAsDirty(force?: boolean): void;
  71952. /** @hidden */
  71953. _markAllAsDirty(): void;
  71954. /** @hidden */
  71955. _link(host: AdvancedDynamicTexture): void;
  71956. /** @hidden */
  71957. protected _transform(context?: CanvasRenderingContext2D): void;
  71958. /** @hidden */
  71959. _renderHighlight(context: CanvasRenderingContext2D): void;
  71960. /** @hidden */
  71961. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71962. /** @hidden */
  71963. protected _applyStates(context: CanvasRenderingContext2D): void;
  71964. /** @hidden */
  71965. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71966. /** @hidden */
  71967. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71968. protected _evaluateClippingState(parentMeasure: Measure): void;
  71969. /** @hidden */
  71970. _measure(): void;
  71971. /** @hidden */
  71972. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71973. /** @hidden */
  71974. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71975. /** @hidden */
  71976. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71977. /** @hidden */
  71978. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71979. private static _ClipMeasure;
  71980. private _tmpMeasureA;
  71981. private _clip;
  71982. /** @hidden */
  71983. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71984. /** @hidden */
  71985. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71986. /**
  71987. * Tests if a given coordinates belong to the current control
  71988. * @param x defines x coordinate to test
  71989. * @param y defines y coordinate to test
  71990. * @returns true if the coordinates are inside the control
  71991. */
  71992. contains(x: number, y: number): boolean;
  71993. /** @hidden */
  71994. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71995. /** @hidden */
  71996. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71997. /** @hidden */
  71998. _onPointerEnter(target: Control): boolean;
  71999. /** @hidden */
  72000. _onPointerOut(target: Control, force?: boolean): void;
  72001. /** @hidden */
  72002. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72003. /** @hidden */
  72004. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72005. /** @hidden */
  72006. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72007. /** @hidden */
  72008. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72009. /** @hidden */
  72010. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72011. private _prepareFont;
  72012. /** Releases associated resources */
  72013. dispose(): void;
  72014. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72015. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72016. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72017. private static _VERTICAL_ALIGNMENT_TOP;
  72018. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72019. private static _VERTICAL_ALIGNMENT_CENTER;
  72020. /** HORIZONTAL_ALIGNMENT_LEFT */
  72021. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72022. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72023. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72024. /** HORIZONTAL_ALIGNMENT_CENTER */
  72025. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72026. /** VERTICAL_ALIGNMENT_TOP */
  72027. static get VERTICAL_ALIGNMENT_TOP(): number;
  72028. /** VERTICAL_ALIGNMENT_BOTTOM */
  72029. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72030. /** VERTICAL_ALIGNMENT_CENTER */
  72031. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72032. private static _FontHeightSizes;
  72033. /** @hidden */
  72034. static _GetFontOffset(font: string): {
  72035. ascent: number;
  72036. height: number;
  72037. descent: number;
  72038. };
  72039. /**
  72040. * Creates a stack panel that can be used to render headers
  72041. * @param control defines the control to associate with the header
  72042. * @param text defines the text of the header
  72043. * @param size defines the size of the header
  72044. * @param options defines options used to configure the header
  72045. * @returns a new StackPanel
  72046. * @ignore
  72047. * @hidden
  72048. */
  72049. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72050. isHorizontal: boolean;
  72051. controlFirst: boolean;
  72052. }) => any;
  72053. /** @hidden */
  72054. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72055. }
  72056. }
  72057. declare module BABYLON.GUI {
  72058. /**
  72059. * Root class for 2D containers
  72060. * @see http://doc.babylonjs.com/how_to/gui#containers
  72061. */
  72062. export class Container extends Control {
  72063. name?: string | undefined;
  72064. /** @hidden */
  72065. _children: Control[];
  72066. /** @hidden */
  72067. protected _measureForChildren: Measure;
  72068. /** @hidden */
  72069. protected _background: string;
  72070. /** @hidden */
  72071. protected _adaptWidthToChildren: boolean;
  72072. /** @hidden */
  72073. protected _adaptHeightToChildren: boolean;
  72074. /**
  72075. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72076. */
  72077. logLayoutCycleErrors: boolean;
  72078. /**
  72079. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72080. */
  72081. maxLayoutCycle: number;
  72082. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72083. get adaptHeightToChildren(): boolean;
  72084. set adaptHeightToChildren(value: boolean);
  72085. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72086. get adaptWidthToChildren(): boolean;
  72087. set adaptWidthToChildren(value: boolean);
  72088. /** Gets or sets background color */
  72089. get background(): string;
  72090. set background(value: string);
  72091. /** Gets the list of children */
  72092. get children(): Control[];
  72093. /**
  72094. * Creates a new Container
  72095. * @param name defines the name of the container
  72096. */
  72097. constructor(name?: string | undefined);
  72098. protected _getTypeName(): string;
  72099. _flagDescendantsAsMatrixDirty(): void;
  72100. /**
  72101. * Gets a child using its name
  72102. * @param name defines the child name to look for
  72103. * @returns the child control if found
  72104. */
  72105. getChildByName(name: string): BABYLON.Nullable<Control>;
  72106. /**
  72107. * Gets a child using its type and its name
  72108. * @param name defines the child name to look for
  72109. * @param type defines the child type to look for
  72110. * @returns the child control if found
  72111. */
  72112. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72113. /**
  72114. * Search for a specific control in children
  72115. * @param control defines the control to look for
  72116. * @returns true if the control is in child list
  72117. */
  72118. containsControl(control: Control): boolean;
  72119. /**
  72120. * Adds a new control to the current container
  72121. * @param control defines the control to add
  72122. * @returns the current container
  72123. */
  72124. addControl(control: BABYLON.Nullable<Control>): Container;
  72125. /**
  72126. * Removes all controls from the current container
  72127. * @returns the current container
  72128. */
  72129. clearControls(): Container;
  72130. /**
  72131. * Removes a control from the current container
  72132. * @param control defines the control to remove
  72133. * @returns the current container
  72134. */
  72135. removeControl(control: Control): Container;
  72136. /** @hidden */
  72137. _reOrderControl(control: Control): void;
  72138. /** @hidden */
  72139. _offsetLeft(offset: number): void;
  72140. /** @hidden */
  72141. _offsetTop(offset: number): void;
  72142. /** @hidden */
  72143. _markAllAsDirty(): void;
  72144. /** @hidden */
  72145. protected _localDraw(context: CanvasRenderingContext2D): void;
  72146. /** @hidden */
  72147. _link(host: AdvancedDynamicTexture): void;
  72148. /** @hidden */
  72149. protected _beforeLayout(): void;
  72150. /** @hidden */
  72151. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72152. /** @hidden */
  72153. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72154. protected _postMeasure(): void;
  72155. /** @hidden */
  72156. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72157. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72158. /** @hidden */
  72159. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72160. /** @hidden */
  72161. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72162. /** Releases associated resources */
  72163. dispose(): void;
  72164. }
  72165. }
  72166. declare module BABYLON.GUI {
  72167. /** Class used to create rectangle container */
  72168. export class Rectangle extends Container {
  72169. name?: string | undefined;
  72170. private _thickness;
  72171. private _cornerRadius;
  72172. /** Gets or sets border thickness */
  72173. get thickness(): number;
  72174. set thickness(value: number);
  72175. /** Gets or sets the corner radius angle */
  72176. get cornerRadius(): number;
  72177. set cornerRadius(value: number);
  72178. /**
  72179. * Creates a new Rectangle
  72180. * @param name defines the control name
  72181. */
  72182. constructor(name?: string | undefined);
  72183. protected _getTypeName(): string;
  72184. protected _localDraw(context: CanvasRenderingContext2D): void;
  72185. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72186. private _drawRoundedRect;
  72187. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72188. }
  72189. }
  72190. declare module BABYLON.GUI {
  72191. /**
  72192. * Enum that determines the text-wrapping mode to use.
  72193. */
  72194. export enum TextWrapping {
  72195. /**
  72196. * Clip the text when it's larger than Control.width; this is the default mode.
  72197. */
  72198. Clip = 0,
  72199. /**
  72200. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72201. */
  72202. WordWrap = 1,
  72203. /**
  72204. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72205. */
  72206. Ellipsis = 2
  72207. }
  72208. /**
  72209. * Class used to create text block control
  72210. */
  72211. export class TextBlock extends Control {
  72212. /**
  72213. * Defines the name of the control
  72214. */
  72215. name?: string | undefined;
  72216. private _text;
  72217. private _textWrapping;
  72218. private _textHorizontalAlignment;
  72219. private _textVerticalAlignment;
  72220. private _lines;
  72221. private _resizeToFit;
  72222. private _lineSpacing;
  72223. private _outlineWidth;
  72224. private _outlineColor;
  72225. /**
  72226. * An event triggered after the text is changed
  72227. */
  72228. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72229. /**
  72230. * An event triggered after the text was broken up into lines
  72231. */
  72232. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72233. /**
  72234. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72235. */
  72236. get lines(): any[];
  72237. /**
  72238. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72239. */
  72240. get resizeToFit(): boolean;
  72241. /**
  72242. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72243. */
  72244. set resizeToFit(value: boolean);
  72245. /**
  72246. * Gets or sets a boolean indicating if text must be wrapped
  72247. */
  72248. get textWrapping(): TextWrapping | boolean;
  72249. /**
  72250. * Gets or sets a boolean indicating if text must be wrapped
  72251. */
  72252. set textWrapping(value: TextWrapping | boolean);
  72253. /**
  72254. * Gets or sets text to display
  72255. */
  72256. get text(): string;
  72257. /**
  72258. * Gets or sets text to display
  72259. */
  72260. set text(value: string);
  72261. /**
  72262. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72263. */
  72264. get textHorizontalAlignment(): number;
  72265. /**
  72266. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72267. */
  72268. set textHorizontalAlignment(value: number);
  72269. /**
  72270. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72271. */
  72272. get textVerticalAlignment(): number;
  72273. /**
  72274. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72275. */
  72276. set textVerticalAlignment(value: number);
  72277. /**
  72278. * Gets or sets line spacing value
  72279. */
  72280. set lineSpacing(value: string | number);
  72281. /**
  72282. * Gets or sets line spacing value
  72283. */
  72284. get lineSpacing(): string | number;
  72285. /**
  72286. * Gets or sets outlineWidth of the text to display
  72287. */
  72288. get outlineWidth(): number;
  72289. /**
  72290. * Gets or sets outlineWidth of the text to display
  72291. */
  72292. set outlineWidth(value: number);
  72293. /**
  72294. * Gets or sets outlineColor of the text to display
  72295. */
  72296. get outlineColor(): string;
  72297. /**
  72298. * Gets or sets outlineColor of the text to display
  72299. */
  72300. set outlineColor(value: string);
  72301. /**
  72302. * Creates a new TextBlock object
  72303. * @param name defines the name of the control
  72304. * @param text defines the text to display (emptry string by default)
  72305. */
  72306. constructor(
  72307. /**
  72308. * Defines the name of the control
  72309. */
  72310. name?: string | undefined, text?: string);
  72311. protected _getTypeName(): string;
  72312. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72313. private _drawText;
  72314. /** @hidden */
  72315. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72316. protected _applyStates(context: CanvasRenderingContext2D): void;
  72317. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72318. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72319. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72320. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72321. protected _renderLines(context: CanvasRenderingContext2D): void;
  72322. /**
  72323. * Given a width constraint applied on the text block, find the expected height
  72324. * @returns expected height
  72325. */
  72326. computeExpectedHeight(): number;
  72327. dispose(): void;
  72328. }
  72329. }
  72330. declare module BABYLON.GUI {
  72331. /**
  72332. * Class used to create 2D images
  72333. */
  72334. export class Image extends Control {
  72335. name?: string | undefined;
  72336. private _workingCanvas;
  72337. private _domImage;
  72338. private _imageWidth;
  72339. private _imageHeight;
  72340. private _loaded;
  72341. private _stretch;
  72342. private _source;
  72343. private _autoScale;
  72344. private _sourceLeft;
  72345. private _sourceTop;
  72346. private _sourceWidth;
  72347. private _sourceHeight;
  72348. private _svgAttributesComputationCompleted;
  72349. private _isSVG;
  72350. private _cellWidth;
  72351. private _cellHeight;
  72352. private _cellId;
  72353. private _populateNinePatchSlicesFromImage;
  72354. private _sliceLeft;
  72355. private _sliceRight;
  72356. private _sliceTop;
  72357. private _sliceBottom;
  72358. private _detectPointerOnOpaqueOnly;
  72359. /**
  72360. * BABYLON.Observable notified when the content is loaded
  72361. */
  72362. onImageLoadedObservable: BABYLON.Observable<Image>;
  72363. /**
  72364. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72365. */
  72366. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72367. /**
  72368. * Gets a boolean indicating that the content is loaded
  72369. */
  72370. get isLoaded(): boolean;
  72371. /**
  72372. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72373. */
  72374. get populateNinePatchSlicesFromImage(): boolean;
  72375. set populateNinePatchSlicesFromImage(value: boolean);
  72376. /**
  72377. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72378. * Beware using this as this will comsume more memory as the image has to be stored twice
  72379. */
  72380. get detectPointerOnOpaqueOnly(): boolean;
  72381. set detectPointerOnOpaqueOnly(value: boolean);
  72382. /**
  72383. * Gets or sets the left value for slicing (9-patch)
  72384. */
  72385. get sliceLeft(): number;
  72386. set sliceLeft(value: number);
  72387. /**
  72388. * Gets or sets the right value for slicing (9-patch)
  72389. */
  72390. get sliceRight(): number;
  72391. set sliceRight(value: number);
  72392. /**
  72393. * Gets or sets the top value for slicing (9-patch)
  72394. */
  72395. get sliceTop(): number;
  72396. set sliceTop(value: number);
  72397. /**
  72398. * Gets or sets the bottom value for slicing (9-patch)
  72399. */
  72400. get sliceBottom(): number;
  72401. set sliceBottom(value: number);
  72402. /**
  72403. * Gets or sets the left coordinate in the source image
  72404. */
  72405. get sourceLeft(): number;
  72406. set sourceLeft(value: number);
  72407. /**
  72408. * Gets or sets the top coordinate in the source image
  72409. */
  72410. get sourceTop(): number;
  72411. set sourceTop(value: number);
  72412. /**
  72413. * Gets or sets the width to capture in the source image
  72414. */
  72415. get sourceWidth(): number;
  72416. set sourceWidth(value: number);
  72417. /**
  72418. * Gets or sets the height to capture in the source image
  72419. */
  72420. get sourceHeight(): number;
  72421. set sourceHeight(value: number);
  72422. /** Indicates if the format of the image is SVG */
  72423. get isSVG(): boolean;
  72424. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72425. get svgAttributesComputationCompleted(): boolean;
  72426. /**
  72427. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72428. * @see http://doc.babylonjs.com/how_to/gui#image
  72429. */
  72430. get autoScale(): boolean;
  72431. set autoScale(value: boolean);
  72432. /** Gets or sets the streching mode used by the image */
  72433. get stretch(): number;
  72434. set stretch(value: number);
  72435. /** @hidden */
  72436. _rotate90(n: number, preserveProperties?: boolean): Image;
  72437. private _handleRotationForSVGImage;
  72438. private _rotate90SourceProperties;
  72439. /**
  72440. * Gets or sets the internal DOM image used to render the control
  72441. */
  72442. set domImage(value: HTMLImageElement);
  72443. get domImage(): HTMLImageElement;
  72444. private _onImageLoaded;
  72445. private _extractNinePatchSliceDataFromImage;
  72446. /**
  72447. * Gets or sets image source url
  72448. */
  72449. set source(value: BABYLON.Nullable<string>);
  72450. /**
  72451. * Checks for svg document with icon id present
  72452. */
  72453. private _svgCheck;
  72454. /**
  72455. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72456. * given external svg file and icon id
  72457. */
  72458. private _getSVGAttribs;
  72459. /**
  72460. * Gets or sets the cell width to use when animation sheet is enabled
  72461. * @see http://doc.babylonjs.com/how_to/gui#image
  72462. */
  72463. get cellWidth(): number;
  72464. set cellWidth(value: number);
  72465. /**
  72466. * Gets or sets the cell height to use when animation sheet is enabled
  72467. * @see http://doc.babylonjs.com/how_to/gui#image
  72468. */
  72469. get cellHeight(): number;
  72470. set cellHeight(value: number);
  72471. /**
  72472. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72473. * @see http://doc.babylonjs.com/how_to/gui#image
  72474. */
  72475. get cellId(): number;
  72476. set cellId(value: number);
  72477. /**
  72478. * Creates a new Image
  72479. * @param name defines the control name
  72480. * @param url defines the image url
  72481. */
  72482. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72483. /**
  72484. * Tests if a given coordinates belong to the current control
  72485. * @param x defines x coordinate to test
  72486. * @param y defines y coordinate to test
  72487. * @returns true if the coordinates are inside the control
  72488. */
  72489. contains(x: number, y: number): boolean;
  72490. protected _getTypeName(): string;
  72491. /** Force the control to synchronize with its content */
  72492. synchronizeSizeWithContent(): void;
  72493. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72494. private _prepareWorkingCanvasForOpaqueDetection;
  72495. private _drawImage;
  72496. _draw(context: CanvasRenderingContext2D): void;
  72497. private _renderCornerPatch;
  72498. private _renderNinePatch;
  72499. dispose(): void;
  72500. /** STRETCH_NONE */
  72501. static readonly STRETCH_NONE: number;
  72502. /** STRETCH_FILL */
  72503. static readonly STRETCH_FILL: number;
  72504. /** STRETCH_UNIFORM */
  72505. static readonly STRETCH_UNIFORM: number;
  72506. /** STRETCH_EXTEND */
  72507. static readonly STRETCH_EXTEND: number;
  72508. /** NINE_PATCH */
  72509. static readonly STRETCH_NINE_PATCH: number;
  72510. }
  72511. }
  72512. declare module BABYLON.GUI {
  72513. /**
  72514. * Class used to create 2D buttons
  72515. */
  72516. export class Button extends Rectangle {
  72517. name?: string | undefined;
  72518. /**
  72519. * Function called to generate a pointer enter animation
  72520. */
  72521. pointerEnterAnimation: () => void;
  72522. /**
  72523. * Function called to generate a pointer out animation
  72524. */
  72525. pointerOutAnimation: () => void;
  72526. /**
  72527. * Function called to generate a pointer down animation
  72528. */
  72529. pointerDownAnimation: () => void;
  72530. /**
  72531. * Function called to generate a pointer up animation
  72532. */
  72533. pointerUpAnimation: () => void;
  72534. /**
  72535. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72536. */
  72537. delegatePickingToChildren: boolean;
  72538. private _image;
  72539. /**
  72540. * Returns the image part of the button (if any)
  72541. */
  72542. get image(): BABYLON.Nullable<Image>;
  72543. private _textBlock;
  72544. /**
  72545. * Returns the image part of the button (if any)
  72546. */
  72547. get textBlock(): BABYLON.Nullable<TextBlock>;
  72548. /**
  72549. * Creates a new Button
  72550. * @param name defines the name of the button
  72551. */
  72552. constructor(name?: string | undefined);
  72553. protected _getTypeName(): string;
  72554. /** @hidden */
  72555. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72556. /** @hidden */
  72557. _onPointerEnter(target: Control): boolean;
  72558. /** @hidden */
  72559. _onPointerOut(target: Control, force?: boolean): void;
  72560. /** @hidden */
  72561. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72562. /** @hidden */
  72563. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72564. /**
  72565. * Creates a new button made with an image and a text
  72566. * @param name defines the name of the button
  72567. * @param text defines the text of the button
  72568. * @param imageUrl defines the url of the image
  72569. * @returns a new Button
  72570. */
  72571. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72572. /**
  72573. * Creates a new button made with an image
  72574. * @param name defines the name of the button
  72575. * @param imageUrl defines the url of the image
  72576. * @returns a new Button
  72577. */
  72578. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72579. /**
  72580. * Creates a new button made with a text
  72581. * @param name defines the name of the button
  72582. * @param text defines the text of the button
  72583. * @returns a new Button
  72584. */
  72585. static CreateSimpleButton(name: string, text: string): Button;
  72586. /**
  72587. * Creates a new button made with an image and a centered text
  72588. * @param name defines the name of the button
  72589. * @param text defines the text of the button
  72590. * @param imageUrl defines the url of the image
  72591. * @returns a new Button
  72592. */
  72593. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72594. }
  72595. }
  72596. declare module BABYLON.GUI {
  72597. /**
  72598. * Class used to create a 2D stack panel container
  72599. */
  72600. export class StackPanel extends Container {
  72601. name?: string | undefined;
  72602. private _isVertical;
  72603. private _manualWidth;
  72604. private _manualHeight;
  72605. private _doNotTrackManualChanges;
  72606. /**
  72607. * Gets or sets a boolean indicating that layou warnings should be ignored
  72608. */
  72609. ignoreLayoutWarnings: boolean;
  72610. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72611. get isVertical(): boolean;
  72612. set isVertical(value: boolean);
  72613. /**
  72614. * Gets or sets panel width.
  72615. * This value should not be set when in horizontal mode as it will be computed automatically
  72616. */
  72617. set width(value: string | number);
  72618. get width(): string | number;
  72619. /**
  72620. * Gets or sets panel height.
  72621. * This value should not be set when in vertical mode as it will be computed automatically
  72622. */
  72623. set height(value: string | number);
  72624. get height(): string | number;
  72625. /**
  72626. * Creates a new StackPanel
  72627. * @param name defines control name
  72628. */
  72629. constructor(name?: string | undefined);
  72630. protected _getTypeName(): string;
  72631. /** @hidden */
  72632. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72633. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72634. protected _postMeasure(): void;
  72635. }
  72636. }
  72637. declare module BABYLON.GUI {
  72638. /**
  72639. * Class used to represent a 2D checkbox
  72640. */
  72641. export class Checkbox extends Control {
  72642. name?: string | undefined;
  72643. private _isChecked;
  72644. private _background;
  72645. private _checkSizeRatio;
  72646. private _thickness;
  72647. /** Gets or sets border thickness */
  72648. get thickness(): number;
  72649. set thickness(value: number);
  72650. /**
  72651. * BABYLON.Observable raised when isChecked property changes
  72652. */
  72653. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72654. /** Gets or sets a value indicating the ratio between overall size and check size */
  72655. get checkSizeRatio(): number;
  72656. set checkSizeRatio(value: number);
  72657. /** Gets or sets background color */
  72658. get background(): string;
  72659. set background(value: string);
  72660. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72661. get isChecked(): boolean;
  72662. set isChecked(value: boolean);
  72663. /**
  72664. * Creates a new CheckBox
  72665. * @param name defines the control name
  72666. */
  72667. constructor(name?: string | undefined);
  72668. protected _getTypeName(): string;
  72669. /** @hidden */
  72670. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72671. /** @hidden */
  72672. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72673. /**
  72674. * Utility function to easily create a checkbox with a header
  72675. * @param title defines the label to use for the header
  72676. * @param onValueChanged defines the callback to call when value changes
  72677. * @returns a StackPanel containing the checkbox and a textBlock
  72678. */
  72679. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72680. }
  72681. }
  72682. declare module BABYLON.GUI {
  72683. /**
  72684. * Class used to store key control properties
  72685. */
  72686. export class KeyPropertySet {
  72687. /** Width */
  72688. width?: string;
  72689. /** Height */
  72690. height?: string;
  72691. /** Left padding */
  72692. paddingLeft?: string;
  72693. /** Right padding */
  72694. paddingRight?: string;
  72695. /** Top padding */
  72696. paddingTop?: string;
  72697. /** Bottom padding */
  72698. paddingBottom?: string;
  72699. /** Foreground color */
  72700. color?: string;
  72701. /** Background color */
  72702. background?: string;
  72703. }
  72704. /**
  72705. * Class used to create virtual keyboard
  72706. */
  72707. export class VirtualKeyboard extends StackPanel {
  72708. /** BABYLON.Observable raised when a key is pressed */
  72709. onKeyPressObservable: BABYLON.Observable<string>;
  72710. /** Gets or sets default key button width */
  72711. defaultButtonWidth: string;
  72712. /** Gets or sets default key button height */
  72713. defaultButtonHeight: string;
  72714. /** Gets or sets default key button left padding */
  72715. defaultButtonPaddingLeft: string;
  72716. /** Gets or sets default key button right padding */
  72717. defaultButtonPaddingRight: string;
  72718. /** Gets or sets default key button top padding */
  72719. defaultButtonPaddingTop: string;
  72720. /** Gets or sets default key button bottom padding */
  72721. defaultButtonPaddingBottom: string;
  72722. /** Gets or sets default key button foreground color */
  72723. defaultButtonColor: string;
  72724. /** Gets or sets default key button background color */
  72725. defaultButtonBackground: string;
  72726. /** Gets or sets shift button foreground color */
  72727. shiftButtonColor: string;
  72728. /** Gets or sets shift button thickness*/
  72729. selectedShiftThickness: number;
  72730. /** Gets shift key state */
  72731. shiftState: number;
  72732. protected _getTypeName(): string;
  72733. private _createKey;
  72734. /**
  72735. * Adds a new row of keys
  72736. * @param keys defines the list of keys to add
  72737. * @param propertySets defines the associated property sets
  72738. */
  72739. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72740. /**
  72741. * Set the shift key to a specific state
  72742. * @param shiftState defines the new shift state
  72743. */
  72744. applyShiftState(shiftState: number): void;
  72745. private _currentlyConnectedInputText;
  72746. private _connectedInputTexts;
  72747. private _onKeyPressObserver;
  72748. /** Gets the input text control currently attached to the keyboard */
  72749. get connectedInputText(): BABYLON.Nullable<InputText>;
  72750. /**
  72751. * Connects the keyboard with an input text control
  72752. *
  72753. * @param input defines the target control
  72754. */
  72755. connect(input: InputText): void;
  72756. /**
  72757. * Disconnects the keyboard from connected InputText controls
  72758. *
  72759. * @param input optionally defines a target control, otherwise all are disconnected
  72760. */
  72761. disconnect(input?: InputText): void;
  72762. private _removeConnectedInputObservables;
  72763. /**
  72764. * Release all resources
  72765. */
  72766. dispose(): void;
  72767. /**
  72768. * Creates a new keyboard using a default layout
  72769. *
  72770. * @param name defines control name
  72771. * @returns a new VirtualKeyboard
  72772. */
  72773. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72774. }
  72775. }
  72776. declare module BABYLON.GUI {
  72777. /**
  72778. * Class used to create input text control
  72779. */
  72780. export class InputText extends Control implements IFocusableControl {
  72781. name?: string | undefined;
  72782. private _text;
  72783. private _placeholderText;
  72784. private _background;
  72785. private _focusedBackground;
  72786. private _focusedColor;
  72787. private _placeholderColor;
  72788. private _thickness;
  72789. private _margin;
  72790. private _autoStretchWidth;
  72791. private _maxWidth;
  72792. private _isFocused;
  72793. private _blinkTimeout;
  72794. private _blinkIsEven;
  72795. private _cursorOffset;
  72796. private _scrollLeft;
  72797. private _textWidth;
  72798. private _clickedCoordinate;
  72799. private _deadKey;
  72800. private _addKey;
  72801. private _currentKey;
  72802. private _isTextHighlightOn;
  72803. private _textHighlightColor;
  72804. private _highligherOpacity;
  72805. private _highlightedText;
  72806. private _startHighlightIndex;
  72807. private _endHighlightIndex;
  72808. private _cursorIndex;
  72809. private _onFocusSelectAll;
  72810. private _isPointerDown;
  72811. private _onClipboardObserver;
  72812. private _onPointerDblTapObserver;
  72813. /** @hidden */
  72814. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72815. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72816. promptMessage: string;
  72817. /** Force disable prompt on mobile device */
  72818. disableMobilePrompt: boolean;
  72819. /** BABYLON.Observable raised when the text changes */
  72820. onTextChangedObservable: BABYLON.Observable<InputText>;
  72821. /** BABYLON.Observable raised just before an entered character is to be added */
  72822. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72823. /** BABYLON.Observable raised when the control gets the focus */
  72824. onFocusObservable: BABYLON.Observable<InputText>;
  72825. /** BABYLON.Observable raised when the control loses the focus */
  72826. onBlurObservable: BABYLON.Observable<InputText>;
  72827. /**Observable raised when the text is highlighted */
  72828. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72829. /**Observable raised when copy event is triggered */
  72830. onTextCopyObservable: BABYLON.Observable<InputText>;
  72831. /** BABYLON.Observable raised when cut event is triggered */
  72832. onTextCutObservable: BABYLON.Observable<InputText>;
  72833. /** BABYLON.Observable raised when paste event is triggered */
  72834. onTextPasteObservable: BABYLON.Observable<InputText>;
  72835. /** BABYLON.Observable raised when a key event was processed */
  72836. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72837. /** Gets or sets the maximum width allowed by the control */
  72838. get maxWidth(): string | number;
  72839. /** Gets the maximum width allowed by the control in pixels */
  72840. get maxWidthInPixels(): number;
  72841. set maxWidth(value: string | number);
  72842. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72843. get highligherOpacity(): number;
  72844. set highligherOpacity(value: number);
  72845. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72846. get onFocusSelectAll(): boolean;
  72847. set onFocusSelectAll(value: boolean);
  72848. /** Gets or sets the text hightlight color */
  72849. get textHighlightColor(): string;
  72850. set textHighlightColor(value: string);
  72851. /** Gets or sets control margin */
  72852. get margin(): string;
  72853. /** Gets control margin in pixels */
  72854. get marginInPixels(): number;
  72855. set margin(value: string);
  72856. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72857. get autoStretchWidth(): boolean;
  72858. set autoStretchWidth(value: boolean);
  72859. /** Gets or sets border thickness */
  72860. get thickness(): number;
  72861. set thickness(value: number);
  72862. /** Gets or sets the background color when focused */
  72863. get focusedBackground(): string;
  72864. set focusedBackground(value: string);
  72865. /** Gets or sets the background color when focused */
  72866. get focusedColor(): string;
  72867. set focusedColor(value: string);
  72868. /** Gets or sets the background color */
  72869. get background(): string;
  72870. set background(value: string);
  72871. /** Gets or sets the placeholder color */
  72872. get placeholderColor(): string;
  72873. set placeholderColor(value: string);
  72874. /** Gets or sets the text displayed when the control is empty */
  72875. get placeholderText(): string;
  72876. set placeholderText(value: string);
  72877. /** Gets or sets the dead key flag */
  72878. get deadKey(): boolean;
  72879. set deadKey(flag: boolean);
  72880. /** Gets or sets the highlight text */
  72881. get highlightedText(): string;
  72882. set highlightedText(text: string);
  72883. /** Gets or sets if the current key should be added */
  72884. get addKey(): boolean;
  72885. set addKey(flag: boolean);
  72886. /** Gets or sets the value of the current key being entered */
  72887. get currentKey(): string;
  72888. set currentKey(key: string);
  72889. /** Gets or sets the text displayed in the control */
  72890. get text(): string;
  72891. set text(value: string);
  72892. /** Gets or sets control width */
  72893. get width(): string | number;
  72894. set width(value: string | number);
  72895. /**
  72896. * Creates a new InputText
  72897. * @param name defines the control name
  72898. * @param text defines the text of the control
  72899. */
  72900. constructor(name?: string | undefined, text?: string);
  72901. /** @hidden */
  72902. onBlur(): void;
  72903. /** @hidden */
  72904. onFocus(): void;
  72905. protected _getTypeName(): string;
  72906. /**
  72907. * Function called to get the list of controls that should not steal the focus from this control
  72908. * @returns an array of controls
  72909. */
  72910. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72911. /** @hidden */
  72912. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72913. /** @hidden */
  72914. private _updateValueFromCursorIndex;
  72915. /** @hidden */
  72916. private _processDblClick;
  72917. /** @hidden */
  72918. private _selectAllText;
  72919. /**
  72920. * Handles the keyboard event
  72921. * @param evt Defines the KeyboardEvent
  72922. */
  72923. processKeyboard(evt: KeyboardEvent): void;
  72924. /** @hidden */
  72925. private _onCopyText;
  72926. /** @hidden */
  72927. private _onCutText;
  72928. /** @hidden */
  72929. private _onPasteText;
  72930. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72931. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72932. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72933. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72934. protected _beforeRenderText(text: string): string;
  72935. dispose(): void;
  72936. }
  72937. }
  72938. declare module BABYLON.GUI {
  72939. /**
  72940. * Class used to create a 2D grid container
  72941. */
  72942. export class Grid extends Container {
  72943. name?: string | undefined;
  72944. private _rowDefinitions;
  72945. private _columnDefinitions;
  72946. private _cells;
  72947. private _childControls;
  72948. /**
  72949. * Gets the number of columns
  72950. */
  72951. get columnCount(): number;
  72952. /**
  72953. * Gets the number of rows
  72954. */
  72955. get rowCount(): number;
  72956. /** Gets the list of children */
  72957. get children(): Control[];
  72958. /** Gets the list of cells (e.g. the containers) */
  72959. get cells(): {
  72960. [key: string]: Container;
  72961. };
  72962. /**
  72963. * Gets the definition of a specific row
  72964. * @param index defines the index of the row
  72965. * @returns the row definition
  72966. */
  72967. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72968. /**
  72969. * Gets the definition of a specific column
  72970. * @param index defines the index of the column
  72971. * @returns the column definition
  72972. */
  72973. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72974. /**
  72975. * Adds a new row to the grid
  72976. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72977. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72978. * @returns the current grid
  72979. */
  72980. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72981. /**
  72982. * Adds a new column to the grid
  72983. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72984. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72985. * @returns the current grid
  72986. */
  72987. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72988. /**
  72989. * Update a row definition
  72990. * @param index defines the index of the row to update
  72991. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72992. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72993. * @returns the current grid
  72994. */
  72995. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72996. /**
  72997. * Update a column definition
  72998. * @param index defines the index of the column to update
  72999. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73000. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73001. * @returns the current grid
  73002. */
  73003. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73004. /**
  73005. * Gets the list of children stored in a specific cell
  73006. * @param row defines the row to check
  73007. * @param column defines the column to check
  73008. * @returns the list of controls
  73009. */
  73010. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73011. /**
  73012. * Gets a string representing the child cell info (row x column)
  73013. * @param child defines the control to get info from
  73014. * @returns a string containing the child cell info (row x column)
  73015. */
  73016. getChildCellInfo(child: Control): string;
  73017. private _removeCell;
  73018. private _offsetCell;
  73019. /**
  73020. * Remove a column definition at specified index
  73021. * @param index defines the index of the column to remove
  73022. * @returns the current grid
  73023. */
  73024. removeColumnDefinition(index: number): Grid;
  73025. /**
  73026. * Remove a row definition at specified index
  73027. * @param index defines the index of the row to remove
  73028. * @returns the current grid
  73029. */
  73030. removeRowDefinition(index: number): Grid;
  73031. /**
  73032. * Adds a new control to the current grid
  73033. * @param control defines the control to add
  73034. * @param row defines the row where to add the control (0 by default)
  73035. * @param column defines the column where to add the control (0 by default)
  73036. * @returns the current grid
  73037. */
  73038. addControl(control: Control, row?: number, column?: number): Grid;
  73039. /**
  73040. * Removes a control from the current container
  73041. * @param control defines the control to remove
  73042. * @returns the current container
  73043. */
  73044. removeControl(control: Control): Container;
  73045. /**
  73046. * Creates a new Grid
  73047. * @param name defines control name
  73048. */
  73049. constructor(name?: string | undefined);
  73050. protected _getTypeName(): string;
  73051. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73052. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73053. _flagDescendantsAsMatrixDirty(): void;
  73054. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73055. /** Releases associated resources */
  73056. dispose(): void;
  73057. }
  73058. }
  73059. declare module BABYLON.GUI {
  73060. /** Class used to create color pickers */
  73061. export class ColorPicker extends Control {
  73062. name?: string | undefined;
  73063. private static _Epsilon;
  73064. private _colorWheelCanvas;
  73065. private _value;
  73066. private _tmpColor;
  73067. private _pointerStartedOnSquare;
  73068. private _pointerStartedOnWheel;
  73069. private _squareLeft;
  73070. private _squareTop;
  73071. private _squareSize;
  73072. private _h;
  73073. private _s;
  73074. private _v;
  73075. private _lastPointerDownID;
  73076. /**
  73077. * BABYLON.Observable raised when the value changes
  73078. */
  73079. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73080. /** Gets or sets the color of the color picker */
  73081. get value(): BABYLON.Color3;
  73082. set value(value: BABYLON.Color3);
  73083. /**
  73084. * Gets or sets control width
  73085. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73086. */
  73087. get width(): string | number;
  73088. set width(value: string | number);
  73089. /**
  73090. * Gets or sets control height
  73091. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73092. */
  73093. get height(): string | number;
  73094. /** Gets or sets control height */
  73095. set height(value: string | number);
  73096. /** Gets or sets control size */
  73097. get size(): string | number;
  73098. set size(value: string | number);
  73099. /**
  73100. * Creates a new ColorPicker
  73101. * @param name defines the control name
  73102. */
  73103. constructor(name?: string | undefined);
  73104. protected _getTypeName(): string;
  73105. /** @hidden */
  73106. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73107. private _updateSquareProps;
  73108. private _drawGradientSquare;
  73109. private _drawCircle;
  73110. private _createColorWheelCanvas;
  73111. /** @hidden */
  73112. _draw(context: CanvasRenderingContext2D): void;
  73113. private _pointerIsDown;
  73114. private _updateValueFromPointer;
  73115. private _isPointOnSquare;
  73116. private _isPointOnWheel;
  73117. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73118. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73119. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73120. /**
  73121. * This function expands the color picker by creating a color picker dialog with manual
  73122. * color value input and the ability to save colors into an array to be used later in
  73123. * subsequent launches of the dialogue.
  73124. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73125. * @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.
  73126. * @returns picked color as a hex string and the saved colors array as hex strings.
  73127. */
  73128. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73129. pickerWidth?: string;
  73130. pickerHeight?: string;
  73131. headerHeight?: string;
  73132. lastColor?: string;
  73133. swatchLimit?: number;
  73134. numSwatchesPerLine?: number;
  73135. savedColors?: Array<string>;
  73136. }): Promise<{
  73137. savedColors?: string[];
  73138. pickedColor: string;
  73139. }>;
  73140. }
  73141. }
  73142. declare module BABYLON.GUI {
  73143. /** Class used to create 2D ellipse containers */
  73144. export class Ellipse extends Container {
  73145. name?: string | undefined;
  73146. private _thickness;
  73147. /** Gets or sets border thickness */
  73148. get thickness(): number;
  73149. set thickness(value: number);
  73150. /**
  73151. * Creates a new Ellipse
  73152. * @param name defines the control name
  73153. */
  73154. constructor(name?: string | undefined);
  73155. protected _getTypeName(): string;
  73156. protected _localDraw(context: CanvasRenderingContext2D): void;
  73157. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73158. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73159. }
  73160. }
  73161. declare module BABYLON.GUI {
  73162. /**
  73163. * Class used to create a password control
  73164. */
  73165. export class InputPassword extends InputText {
  73166. protected _beforeRenderText(text: string): string;
  73167. }
  73168. }
  73169. declare module BABYLON.GUI {
  73170. /** Class used to render 2D lines */
  73171. export class Line extends Control {
  73172. name?: string | undefined;
  73173. private _lineWidth;
  73174. private _x1;
  73175. private _y1;
  73176. private _x2;
  73177. private _y2;
  73178. private _dash;
  73179. private _connectedControl;
  73180. private _connectedControlDirtyObserver;
  73181. /** Gets or sets the dash pattern */
  73182. get dash(): Array<number>;
  73183. set dash(value: Array<number>);
  73184. /** Gets or sets the control connected with the line end */
  73185. get connectedControl(): Control;
  73186. set connectedControl(value: Control);
  73187. /** Gets or sets start coordinates on X axis */
  73188. get x1(): string | number;
  73189. set x1(value: string | number);
  73190. /** Gets or sets start coordinates on Y axis */
  73191. get y1(): string | number;
  73192. set y1(value: string | number);
  73193. /** Gets or sets end coordinates on X axis */
  73194. get x2(): string | number;
  73195. set x2(value: string | number);
  73196. /** Gets or sets end coordinates on Y axis */
  73197. get y2(): string | number;
  73198. set y2(value: string | number);
  73199. /** Gets or sets line width */
  73200. get lineWidth(): number;
  73201. set lineWidth(value: number);
  73202. /** Gets or sets horizontal alignment */
  73203. set horizontalAlignment(value: number);
  73204. /** Gets or sets vertical alignment */
  73205. set verticalAlignment(value: number);
  73206. private get _effectiveX2();
  73207. private get _effectiveY2();
  73208. /**
  73209. * Creates a new Line
  73210. * @param name defines the control name
  73211. */
  73212. constructor(name?: string | undefined);
  73213. protected _getTypeName(): string;
  73214. _draw(context: CanvasRenderingContext2D): void;
  73215. _measure(): void;
  73216. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73217. /**
  73218. * Move one end of the line given 3D cartesian coordinates.
  73219. * @param position Targeted world position
  73220. * @param scene BABYLON.Scene
  73221. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73222. */
  73223. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73224. /**
  73225. * Move one end of the line to a position in screen absolute space.
  73226. * @param projectedPosition Position in screen absolute space (X, Y)
  73227. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73228. */
  73229. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73230. }
  73231. }
  73232. declare module BABYLON.GUI {
  73233. /**
  73234. * Class used to store a point for a MultiLine object.
  73235. * The point can be pure 2D coordinates, a mesh or a control
  73236. */
  73237. export class MultiLinePoint {
  73238. private _multiLine;
  73239. private _x;
  73240. private _y;
  73241. private _control;
  73242. private _mesh;
  73243. private _controlObserver;
  73244. private _meshObserver;
  73245. /** @hidden */
  73246. _point: BABYLON.Vector2;
  73247. /**
  73248. * Creates a new MultiLinePoint
  73249. * @param multiLine defines the source MultiLine object
  73250. */
  73251. constructor(multiLine: MultiLine);
  73252. /** Gets or sets x coordinate */
  73253. get x(): string | number;
  73254. set x(value: string | number);
  73255. /** Gets or sets y coordinate */
  73256. get y(): string | number;
  73257. set y(value: string | number);
  73258. /** Gets or sets the control associated with this point */
  73259. get control(): BABYLON.Nullable<Control>;
  73260. set control(value: BABYLON.Nullable<Control>);
  73261. /** Gets or sets the mesh associated with this point */
  73262. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73263. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73264. /** Resets links */
  73265. resetLinks(): void;
  73266. /**
  73267. * Gets a translation vector
  73268. * @returns the translation vector
  73269. */
  73270. translate(): BABYLON.Vector2;
  73271. private _translatePoint;
  73272. /** Release associated resources */
  73273. dispose(): void;
  73274. }
  73275. }
  73276. declare module BABYLON.GUI {
  73277. /**
  73278. * Class used to create multi line control
  73279. */
  73280. export class MultiLine extends Control {
  73281. name?: string | undefined;
  73282. private _lineWidth;
  73283. private _dash;
  73284. private _points;
  73285. private _minX;
  73286. private _minY;
  73287. private _maxX;
  73288. private _maxY;
  73289. /**
  73290. * Creates a new MultiLine
  73291. * @param name defines the control name
  73292. */
  73293. constructor(name?: string | undefined);
  73294. /** Gets or sets dash pattern */
  73295. get dash(): Array<number>;
  73296. set dash(value: Array<number>);
  73297. /**
  73298. * Gets point stored at specified index
  73299. * @param index defines the index to look for
  73300. * @returns the requested point if found
  73301. */
  73302. getAt(index: number): MultiLinePoint;
  73303. /** Function called when a point is updated */
  73304. onPointUpdate: () => void;
  73305. /**
  73306. * Adds new points to the point collection
  73307. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73308. * @returns the list of created MultiLinePoint
  73309. */
  73310. add(...items: (AbstractMesh | Control | {
  73311. x: string | number;
  73312. y: string | number;
  73313. })[]): MultiLinePoint[];
  73314. /**
  73315. * Adds a new point to the point collection
  73316. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73317. * @returns the created MultiLinePoint
  73318. */
  73319. push(item?: (AbstractMesh | Control | {
  73320. x: string | number;
  73321. y: string | number;
  73322. })): MultiLinePoint;
  73323. /**
  73324. * Remove a specific value or point from the active point collection
  73325. * @param value defines the value or point to remove
  73326. */
  73327. remove(value: number | MultiLinePoint): void;
  73328. /**
  73329. * Resets this object to initial state (no point)
  73330. */
  73331. reset(): void;
  73332. /**
  73333. * Resets all links
  73334. */
  73335. resetLinks(): void;
  73336. /** Gets or sets line width */
  73337. get lineWidth(): number;
  73338. set lineWidth(value: number);
  73339. set horizontalAlignment(value: number);
  73340. set verticalAlignment(value: number);
  73341. protected _getTypeName(): string;
  73342. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73343. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73344. _measure(): void;
  73345. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73346. dispose(): void;
  73347. }
  73348. }
  73349. declare module BABYLON.GUI {
  73350. /**
  73351. * Class used to create radio button controls
  73352. */
  73353. export class RadioButton extends Control {
  73354. name?: string | undefined;
  73355. private _isChecked;
  73356. private _background;
  73357. private _checkSizeRatio;
  73358. private _thickness;
  73359. /** Gets or sets border thickness */
  73360. get thickness(): number;
  73361. set thickness(value: number);
  73362. /** Gets or sets group name */
  73363. group: string;
  73364. /** BABYLON.Observable raised when isChecked is changed */
  73365. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73366. /** Gets or sets a value indicating the ratio between overall size and check size */
  73367. get checkSizeRatio(): number;
  73368. set checkSizeRatio(value: number);
  73369. /** Gets or sets background color */
  73370. get background(): string;
  73371. set background(value: string);
  73372. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73373. get isChecked(): boolean;
  73374. set isChecked(value: boolean);
  73375. /**
  73376. * Creates a new RadioButton
  73377. * @param name defines the control name
  73378. */
  73379. constructor(name?: string | undefined);
  73380. protected _getTypeName(): string;
  73381. _draw(context: CanvasRenderingContext2D): void;
  73382. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73383. /**
  73384. * Utility function to easily create a radio button with a header
  73385. * @param title defines the label to use for the header
  73386. * @param group defines the group to use for the radio button
  73387. * @param isChecked defines the initial state of the radio button
  73388. * @param onValueChanged defines the callback to call when value changes
  73389. * @returns a StackPanel containing the radio button and a textBlock
  73390. */
  73391. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73392. }
  73393. }
  73394. declare module BABYLON.GUI {
  73395. /**
  73396. * Class used to create slider controls
  73397. */
  73398. export class BaseSlider extends Control {
  73399. name?: string | undefined;
  73400. protected _thumbWidth: ValueAndUnit;
  73401. private _minimum;
  73402. private _maximum;
  73403. private _value;
  73404. private _isVertical;
  73405. protected _barOffset: ValueAndUnit;
  73406. private _isThumbClamped;
  73407. protected _displayThumb: boolean;
  73408. private _step;
  73409. private _lastPointerDownID;
  73410. protected _effectiveBarOffset: number;
  73411. protected _renderLeft: number;
  73412. protected _renderTop: number;
  73413. protected _renderWidth: number;
  73414. protected _renderHeight: number;
  73415. protected _backgroundBoxLength: number;
  73416. protected _backgroundBoxThickness: number;
  73417. protected _effectiveThumbThickness: number;
  73418. /** BABYLON.Observable raised when the sldier value changes */
  73419. onValueChangedObservable: BABYLON.Observable<number>;
  73420. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73421. get displayThumb(): boolean;
  73422. set displayThumb(value: boolean);
  73423. /** Gets or sets a step to apply to values (0 by default) */
  73424. get step(): number;
  73425. set step(value: number);
  73426. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73427. get barOffset(): string | number;
  73428. /** Gets main bar offset in pixels*/
  73429. get barOffsetInPixels(): number;
  73430. set barOffset(value: string | number);
  73431. /** Gets or sets thumb width */
  73432. get thumbWidth(): string | number;
  73433. /** Gets thumb width in pixels */
  73434. get thumbWidthInPixels(): number;
  73435. set thumbWidth(value: string | number);
  73436. /** Gets or sets minimum value */
  73437. get minimum(): number;
  73438. set minimum(value: number);
  73439. /** Gets or sets maximum value */
  73440. get maximum(): number;
  73441. set maximum(value: number);
  73442. /** Gets or sets current value */
  73443. get value(): number;
  73444. set value(value: number);
  73445. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73446. get isVertical(): boolean;
  73447. set isVertical(value: boolean);
  73448. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73449. get isThumbClamped(): boolean;
  73450. set isThumbClamped(value: boolean);
  73451. /**
  73452. * Creates a new BaseSlider
  73453. * @param name defines the control name
  73454. */
  73455. constructor(name?: string | undefined);
  73456. protected _getTypeName(): string;
  73457. protected _getThumbPosition(): number;
  73458. protected _getThumbThickness(type: string): number;
  73459. protected _prepareRenderingData(type: string): void;
  73460. private _pointerIsDown;
  73461. /** @hidden */
  73462. protected _updateValueFromPointer(x: number, y: number): void;
  73463. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73464. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73465. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73466. }
  73467. }
  73468. declare module BABYLON.GUI {
  73469. /**
  73470. * Class used to create slider controls
  73471. */
  73472. export class Slider extends BaseSlider {
  73473. name?: string | undefined;
  73474. private _background;
  73475. private _borderColor;
  73476. private _isThumbCircle;
  73477. protected _displayValueBar: boolean;
  73478. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73479. get displayValueBar(): boolean;
  73480. set displayValueBar(value: boolean);
  73481. /** Gets or sets border color */
  73482. get borderColor(): string;
  73483. set borderColor(value: string);
  73484. /** Gets or sets background color */
  73485. get background(): string;
  73486. set background(value: string);
  73487. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73488. get isThumbCircle(): boolean;
  73489. set isThumbCircle(value: boolean);
  73490. /**
  73491. * Creates a new Slider
  73492. * @param name defines the control name
  73493. */
  73494. constructor(name?: string | undefined);
  73495. protected _getTypeName(): string;
  73496. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73497. }
  73498. }
  73499. declare module BABYLON.GUI {
  73500. /** Class used to create a RadioGroup
  73501. * which contains groups of radio buttons
  73502. */
  73503. export class SelectorGroup {
  73504. /** name of SelectorGroup */
  73505. name: string;
  73506. private _groupPanel;
  73507. private _selectors;
  73508. private _groupHeader;
  73509. /**
  73510. * Creates a new SelectorGroup
  73511. * @param name of group, used as a group heading
  73512. */
  73513. constructor(
  73514. /** name of SelectorGroup */
  73515. name: string);
  73516. /** Gets the groupPanel of the SelectorGroup */
  73517. get groupPanel(): StackPanel;
  73518. /** Gets the selectors array */
  73519. get selectors(): StackPanel[];
  73520. /** Gets and sets the group header */
  73521. get header(): string;
  73522. set header(label: string);
  73523. /** @hidden */
  73524. private _addGroupHeader;
  73525. /** @hidden*/
  73526. _getSelector(selectorNb: number): StackPanel | undefined;
  73527. /** Removes the selector at the given position
  73528. * @param selectorNb the position of the selector within the group
  73529. */
  73530. removeSelector(selectorNb: number): void;
  73531. }
  73532. /** Class used to create a CheckboxGroup
  73533. * which contains groups of checkbox buttons
  73534. */
  73535. export class CheckboxGroup extends SelectorGroup {
  73536. /** Adds a checkbox as a control
  73537. * @param text is the label for the selector
  73538. * @param func is the function called when the Selector is checked
  73539. * @param checked is true when Selector is checked
  73540. */
  73541. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73542. /** @hidden */
  73543. _setSelectorLabel(selectorNb: number, label: string): void;
  73544. /** @hidden */
  73545. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73546. /** @hidden */
  73547. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73548. /** @hidden */
  73549. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73550. }
  73551. /** Class used to create a RadioGroup
  73552. * which contains groups of radio buttons
  73553. */
  73554. export class RadioGroup extends SelectorGroup {
  73555. private _selectNb;
  73556. /** Adds a radio button as a control
  73557. * @param label is the label for the selector
  73558. * @param func is the function called when the Selector is checked
  73559. * @param checked is true when Selector is checked
  73560. */
  73561. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73562. /** @hidden */
  73563. _setSelectorLabel(selectorNb: number, label: string): void;
  73564. /** @hidden */
  73565. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73566. /** @hidden */
  73567. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73568. /** @hidden */
  73569. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73570. }
  73571. /** Class used to create a SliderGroup
  73572. * which contains groups of slider buttons
  73573. */
  73574. export class SliderGroup extends SelectorGroup {
  73575. /**
  73576. * Adds a slider to the SelectorGroup
  73577. * @param label is the label for the SliderBar
  73578. * @param func is the function called when the Slider moves
  73579. * @param unit is a string describing the units used, eg degrees or metres
  73580. * @param min is the minimum value for the Slider
  73581. * @param max is the maximum value for the Slider
  73582. * @param value is the start value for the Slider between min and max
  73583. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73584. */
  73585. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73586. /** @hidden */
  73587. _setSelectorLabel(selectorNb: number, label: string): void;
  73588. /** @hidden */
  73589. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73590. /** @hidden */
  73591. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73592. /** @hidden */
  73593. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73594. }
  73595. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73596. * @see http://doc.babylonjs.com/how_to/selector
  73597. */
  73598. export class SelectionPanel extends Rectangle {
  73599. /** name of SelectionPanel */
  73600. name: string;
  73601. /** an array of SelectionGroups */
  73602. groups: SelectorGroup[];
  73603. private _panel;
  73604. private _buttonColor;
  73605. private _buttonBackground;
  73606. private _headerColor;
  73607. private _barColor;
  73608. private _barHeight;
  73609. private _spacerHeight;
  73610. private _labelColor;
  73611. private _groups;
  73612. private _bars;
  73613. /**
  73614. * Creates a new SelectionPanel
  73615. * @param name of SelectionPanel
  73616. * @param groups is an array of SelectionGroups
  73617. */
  73618. constructor(
  73619. /** name of SelectionPanel */
  73620. name: string,
  73621. /** an array of SelectionGroups */
  73622. groups?: SelectorGroup[]);
  73623. protected _getTypeName(): string;
  73624. /** Gets or sets the headerColor */
  73625. get headerColor(): string;
  73626. set headerColor(color: string);
  73627. private _setHeaderColor;
  73628. /** Gets or sets the button color */
  73629. get buttonColor(): string;
  73630. set buttonColor(color: string);
  73631. private _setbuttonColor;
  73632. /** Gets or sets the label color */
  73633. get labelColor(): string;
  73634. set labelColor(color: string);
  73635. private _setLabelColor;
  73636. /** Gets or sets the button background */
  73637. get buttonBackground(): string;
  73638. set buttonBackground(color: string);
  73639. private _setButtonBackground;
  73640. /** Gets or sets the color of separator bar */
  73641. get barColor(): string;
  73642. set barColor(color: string);
  73643. private _setBarColor;
  73644. /** Gets or sets the height of separator bar */
  73645. get barHeight(): string;
  73646. set barHeight(value: string);
  73647. private _setBarHeight;
  73648. /** Gets or sets the height of spacers*/
  73649. get spacerHeight(): string;
  73650. set spacerHeight(value: string);
  73651. private _setSpacerHeight;
  73652. /** Adds a bar between groups */
  73653. private _addSpacer;
  73654. /** Add a group to the selection panel
  73655. * @param group is the selector group to add
  73656. */
  73657. addGroup(group: SelectorGroup): void;
  73658. /** Remove the group from the given position
  73659. * @param groupNb is the position of the group in the list
  73660. */
  73661. removeGroup(groupNb: number): void;
  73662. /** Change a group header label
  73663. * @param label is the new group header label
  73664. * @param groupNb is the number of the group to relabel
  73665. * */
  73666. setHeaderName(label: string, groupNb: number): void;
  73667. /** Change selector label to the one given
  73668. * @param label is the new selector label
  73669. * @param groupNb is the number of the groupcontaining the selector
  73670. * @param selectorNb is the number of the selector within a group to relabel
  73671. * */
  73672. relabel(label: string, groupNb: number, selectorNb: number): void;
  73673. /** For a given group position remove the selector at the given position
  73674. * @param groupNb is the number of the group to remove the selector from
  73675. * @param selectorNb is the number of the selector within the group
  73676. */
  73677. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73678. /** For a given group position of correct type add a checkbox button
  73679. * @param groupNb is the number of the group to remove the selector from
  73680. * @param label is the label for the selector
  73681. * @param func is the function called when the Selector is checked
  73682. * @param checked is true when Selector is checked
  73683. */
  73684. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73685. /** For a given group position of correct type add a radio button
  73686. * @param groupNb is the number of the group to remove the selector from
  73687. * @param label is the label for the selector
  73688. * @param func is the function called when the Selector is checked
  73689. * @param checked is true when Selector is checked
  73690. */
  73691. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73692. /**
  73693. * For a given slider group add a slider
  73694. * @param groupNb is the number of the group to add the slider to
  73695. * @param label is the label for the Slider
  73696. * @param func is the function called when the Slider moves
  73697. * @param unit is a string describing the units used, eg degrees or metres
  73698. * @param min is the minimum value for the Slider
  73699. * @param max is the maximum value for the Slider
  73700. * @param value is the start value for the Slider between min and max
  73701. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73702. */
  73703. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73704. }
  73705. }
  73706. declare module BABYLON.GUI {
  73707. /**
  73708. * Class used to hold a the container for ScrollViewer
  73709. * @hidden
  73710. */
  73711. export class _ScrollViewerWindow extends Container {
  73712. parentClientWidth: number;
  73713. parentClientHeight: number;
  73714. private _freezeControls;
  73715. private _parentMeasure;
  73716. private _oldLeft;
  73717. private _oldTop;
  73718. get freezeControls(): boolean;
  73719. set freezeControls(value: boolean);
  73720. private _bucketWidth;
  73721. private _bucketHeight;
  73722. private _buckets;
  73723. private _bucketLen;
  73724. get bucketWidth(): number;
  73725. get bucketHeight(): number;
  73726. setBucketSizes(width: number, height: number): void;
  73727. private _useBuckets;
  73728. private _makeBuckets;
  73729. private _dispatchInBuckets;
  73730. private _updateMeasures;
  73731. private _updateChildrenMeasures;
  73732. private _restoreMeasures;
  73733. /**
  73734. * Creates a new ScrollViewerWindow
  73735. * @param name of ScrollViewerWindow
  73736. */
  73737. constructor(name?: string);
  73738. protected _getTypeName(): string;
  73739. /** @hidden */
  73740. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73741. /** @hidden */
  73742. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73743. private _scrollChildren;
  73744. private _scrollChildrenWithBuckets;
  73745. /** @hidden */
  73746. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73747. protected _postMeasure(): void;
  73748. }
  73749. }
  73750. declare module BABYLON.GUI {
  73751. /**
  73752. * Class used to create slider controls
  73753. */
  73754. export class ScrollBar extends BaseSlider {
  73755. name?: string | undefined;
  73756. private _background;
  73757. private _borderColor;
  73758. private _tempMeasure;
  73759. /** Gets or sets border color */
  73760. get borderColor(): string;
  73761. set borderColor(value: string);
  73762. /** Gets or sets background color */
  73763. get background(): string;
  73764. set background(value: string);
  73765. /**
  73766. * Creates a new Slider
  73767. * @param name defines the control name
  73768. */
  73769. constructor(name?: string | undefined);
  73770. protected _getTypeName(): string;
  73771. protected _getThumbThickness(): number;
  73772. _draw(context: CanvasRenderingContext2D): void;
  73773. private _first;
  73774. private _originX;
  73775. private _originY;
  73776. /** @hidden */
  73777. protected _updateValueFromPointer(x: number, y: number): void;
  73778. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73779. }
  73780. }
  73781. declare module BABYLON.GUI {
  73782. /**
  73783. * Class used to create slider controls
  73784. */
  73785. export class ImageScrollBar extends BaseSlider {
  73786. name?: string | undefined;
  73787. private _backgroundBaseImage;
  73788. private _backgroundImage;
  73789. private _thumbImage;
  73790. private _thumbBaseImage;
  73791. private _thumbLength;
  73792. private _thumbHeight;
  73793. private _barImageHeight;
  73794. private _tempMeasure;
  73795. /** Number of 90° rotation to apply on the images when in vertical mode */
  73796. num90RotationInVerticalMode: number;
  73797. /**
  73798. * Gets or sets the image used to render the background for horizontal bar
  73799. */
  73800. get backgroundImage(): Image;
  73801. set backgroundImage(value: Image);
  73802. /**
  73803. * Gets or sets the image used to render the thumb
  73804. */
  73805. get thumbImage(): Image;
  73806. set thumbImage(value: Image);
  73807. /**
  73808. * Gets or sets the length of the thumb
  73809. */
  73810. get thumbLength(): number;
  73811. set thumbLength(value: number);
  73812. /**
  73813. * Gets or sets the height of the thumb
  73814. */
  73815. get thumbHeight(): number;
  73816. set thumbHeight(value: number);
  73817. /**
  73818. * Gets or sets the height of the bar image
  73819. */
  73820. get barImageHeight(): number;
  73821. set barImageHeight(value: number);
  73822. /**
  73823. * Creates a new ImageScrollBar
  73824. * @param name defines the control name
  73825. */
  73826. constructor(name?: string | undefined);
  73827. protected _getTypeName(): string;
  73828. protected _getThumbThickness(): number;
  73829. _draw(context: CanvasRenderingContext2D): void;
  73830. private _first;
  73831. private _originX;
  73832. private _originY;
  73833. /** @hidden */
  73834. protected _updateValueFromPointer(x: number, y: number): void;
  73835. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73836. }
  73837. }
  73838. declare module BABYLON.GUI {
  73839. /**
  73840. * Class used to hold a viewer window and sliders in a grid
  73841. */
  73842. export class ScrollViewer extends Rectangle {
  73843. private _grid;
  73844. private _horizontalBarSpace;
  73845. private _verticalBarSpace;
  73846. private _dragSpace;
  73847. private _horizontalBar;
  73848. private _verticalBar;
  73849. private _barColor;
  73850. private _barBackground;
  73851. private _barImage;
  73852. private _horizontalBarImage;
  73853. private _verticalBarImage;
  73854. private _barBackgroundImage;
  73855. private _horizontalBarBackgroundImage;
  73856. private _verticalBarBackgroundImage;
  73857. private _barSize;
  73858. private _window;
  73859. private _pointerIsOver;
  73860. private _wheelPrecision;
  73861. private _onWheelObserver;
  73862. private _clientWidth;
  73863. private _clientHeight;
  73864. private _useImageBar;
  73865. private _thumbLength;
  73866. private _thumbHeight;
  73867. private _barImageHeight;
  73868. private _horizontalBarImageHeight;
  73869. private _verticalBarImageHeight;
  73870. /**
  73871. * Gets the horizontal scrollbar
  73872. */
  73873. get horizontalBar(): ScrollBar | ImageScrollBar;
  73874. /**
  73875. * Gets the vertical scrollbar
  73876. */
  73877. get verticalBar(): ScrollBar | ImageScrollBar;
  73878. /**
  73879. * Adds a new control to the current container
  73880. * @param control defines the control to add
  73881. * @returns the current container
  73882. */
  73883. addControl(control: BABYLON.Nullable<Control>): Container;
  73884. /**
  73885. * Removes a control from the current container
  73886. * @param control defines the control to remove
  73887. * @returns the current container
  73888. */
  73889. removeControl(control: Control): Container;
  73890. /** Gets the list of children */
  73891. get children(): Control[];
  73892. _flagDescendantsAsMatrixDirty(): void;
  73893. /**
  73894. * Freezes or unfreezes the controls in the window.
  73895. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73896. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73897. */
  73898. get freezeControls(): boolean;
  73899. set freezeControls(value: boolean);
  73900. /** Gets the bucket width */
  73901. get bucketWidth(): number;
  73902. /** Gets the bucket height */
  73903. get bucketHeight(): number;
  73904. /**
  73905. * Sets the bucket sizes.
  73906. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73907. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73908. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73909. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73910. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73911. * used), that's why it is not enabled by default.
  73912. * @param width width of the bucket
  73913. * @param height height of the bucket
  73914. */
  73915. setBucketSizes(width: number, height: number): void;
  73916. private _forceHorizontalBar;
  73917. private _forceVerticalBar;
  73918. /**
  73919. * Forces the horizontal scroll bar to be displayed
  73920. */
  73921. get forceHorizontalBar(): boolean;
  73922. set forceHorizontalBar(value: boolean);
  73923. /**
  73924. * Forces the vertical scroll bar to be displayed
  73925. */
  73926. get forceVerticalBar(): boolean;
  73927. set forceVerticalBar(value: boolean);
  73928. /**
  73929. * Creates a new ScrollViewer
  73930. * @param name of ScrollViewer
  73931. */
  73932. constructor(name?: string, isImageBased?: boolean);
  73933. /** Reset the scroll viewer window to initial size */
  73934. resetWindow(): void;
  73935. protected _getTypeName(): string;
  73936. private _buildClientSizes;
  73937. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73938. protected _postMeasure(): void;
  73939. /**
  73940. * Gets or sets the mouse wheel precision
  73941. * from 0 to 1 with a default value of 0.05
  73942. * */
  73943. get wheelPrecision(): number;
  73944. set wheelPrecision(value: number);
  73945. /** Gets or sets the scroll bar container background color */
  73946. get scrollBackground(): string;
  73947. set scrollBackground(color: string);
  73948. /** Gets or sets the bar color */
  73949. get barColor(): string;
  73950. set barColor(color: string);
  73951. /** Gets or sets the bar image */
  73952. get thumbImage(): Image;
  73953. set thumbImage(value: Image);
  73954. /** Gets or sets the horizontal bar image */
  73955. get horizontalThumbImage(): Image;
  73956. set horizontalThumbImage(value: Image);
  73957. /** Gets or sets the vertical bar image */
  73958. get verticalThumbImage(): Image;
  73959. set verticalThumbImage(value: Image);
  73960. /** Gets or sets the size of the bar */
  73961. get barSize(): number;
  73962. set barSize(value: number);
  73963. /** Gets or sets the length of the thumb */
  73964. get thumbLength(): number;
  73965. set thumbLength(value: number);
  73966. /** Gets or sets the height of the thumb */
  73967. get thumbHeight(): number;
  73968. set thumbHeight(value: number);
  73969. /** Gets or sets the height of the bar image */
  73970. get barImageHeight(): number;
  73971. set barImageHeight(value: number);
  73972. /** Gets or sets the height of the horizontal bar image */
  73973. get horizontalBarImageHeight(): number;
  73974. set horizontalBarImageHeight(value: number);
  73975. /** Gets or sets the height of the vertical bar image */
  73976. get verticalBarImageHeight(): number;
  73977. set verticalBarImageHeight(value: number);
  73978. /** Gets or sets the bar background */
  73979. get barBackground(): string;
  73980. set barBackground(color: string);
  73981. /** Gets or sets the bar background image */
  73982. get barImage(): Image;
  73983. set barImage(value: Image);
  73984. /** Gets or sets the horizontal bar background image */
  73985. get horizontalBarImage(): Image;
  73986. set horizontalBarImage(value: Image);
  73987. /** Gets or sets the vertical bar background image */
  73988. get verticalBarImage(): Image;
  73989. set verticalBarImage(value: Image);
  73990. private _setWindowPosition;
  73991. /** @hidden */
  73992. private _updateScroller;
  73993. _link(host: AdvancedDynamicTexture): void;
  73994. /** @hidden */
  73995. private _addBar;
  73996. /** @hidden */
  73997. private _attachWheel;
  73998. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73999. /** Releases associated resources */
  74000. dispose(): void;
  74001. }
  74002. }
  74003. declare module BABYLON.GUI {
  74004. /** Class used to render a grid */
  74005. export class DisplayGrid extends Control {
  74006. name?: string | undefined;
  74007. private _cellWidth;
  74008. private _cellHeight;
  74009. private _minorLineTickness;
  74010. private _minorLineColor;
  74011. private _majorLineTickness;
  74012. private _majorLineColor;
  74013. private _majorLineFrequency;
  74014. private _background;
  74015. private _displayMajorLines;
  74016. private _displayMinorLines;
  74017. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74018. get displayMinorLines(): boolean;
  74019. set displayMinorLines(value: boolean);
  74020. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74021. get displayMajorLines(): boolean;
  74022. set displayMajorLines(value: boolean);
  74023. /** Gets or sets background color (Black by default) */
  74024. get background(): string;
  74025. set background(value: string);
  74026. /** Gets or sets the width of each cell (20 by default) */
  74027. get cellWidth(): number;
  74028. set cellWidth(value: number);
  74029. /** Gets or sets the height of each cell (20 by default) */
  74030. get cellHeight(): number;
  74031. set cellHeight(value: number);
  74032. /** Gets or sets the tickness of minor lines (1 by default) */
  74033. get minorLineTickness(): number;
  74034. set minorLineTickness(value: number);
  74035. /** Gets or sets the color of minor lines (DarkGray by default) */
  74036. get minorLineColor(): string;
  74037. set minorLineColor(value: string);
  74038. /** Gets or sets the tickness of major lines (2 by default) */
  74039. get majorLineTickness(): number;
  74040. set majorLineTickness(value: number);
  74041. /** Gets or sets the color of major lines (White by default) */
  74042. get majorLineColor(): string;
  74043. set majorLineColor(value: string);
  74044. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74045. get majorLineFrequency(): number;
  74046. set majorLineFrequency(value: number);
  74047. /**
  74048. * Creates a new GridDisplayRectangle
  74049. * @param name defines the control name
  74050. */
  74051. constructor(name?: string | undefined);
  74052. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74053. protected _getTypeName(): string;
  74054. }
  74055. }
  74056. declare module BABYLON.GUI {
  74057. /**
  74058. * Class used to create slider controls based on images
  74059. */
  74060. export class ImageBasedSlider extends BaseSlider {
  74061. name?: string | undefined;
  74062. private _backgroundImage;
  74063. private _thumbImage;
  74064. private _valueBarImage;
  74065. private _tempMeasure;
  74066. get displayThumb(): boolean;
  74067. set displayThumb(value: boolean);
  74068. /**
  74069. * Gets or sets the image used to render the background
  74070. */
  74071. get backgroundImage(): Image;
  74072. set backgroundImage(value: Image);
  74073. /**
  74074. * Gets or sets the image used to render the value bar
  74075. */
  74076. get valueBarImage(): Image;
  74077. set valueBarImage(value: Image);
  74078. /**
  74079. * Gets or sets the image used to render the thumb
  74080. */
  74081. get thumbImage(): Image;
  74082. set thumbImage(value: Image);
  74083. /**
  74084. * Creates a new ImageBasedSlider
  74085. * @param name defines the control name
  74086. */
  74087. constructor(name?: string | undefined);
  74088. protected _getTypeName(): string;
  74089. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74090. }
  74091. }
  74092. declare module BABYLON.GUI {
  74093. /**
  74094. * Forcing an export so that this code will execute
  74095. * @hidden
  74096. */
  74097. const name = "Statics";
  74098. }
  74099. declare module BABYLON.GUI {
  74100. /**
  74101. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74102. */
  74103. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74104. /**
  74105. * Define the instrumented AdvancedDynamicTexture.
  74106. */
  74107. texture: AdvancedDynamicTexture;
  74108. private _captureRenderTime;
  74109. private _renderTime;
  74110. private _captureLayoutTime;
  74111. private _layoutTime;
  74112. private _onBeginRenderObserver;
  74113. private _onEndRenderObserver;
  74114. private _onBeginLayoutObserver;
  74115. private _onEndLayoutObserver;
  74116. /**
  74117. * Gets the perf counter used to capture render time
  74118. */
  74119. get renderTimeCounter(): BABYLON.PerfCounter;
  74120. /**
  74121. * Gets the perf counter used to capture layout time
  74122. */
  74123. get layoutTimeCounter(): BABYLON.PerfCounter;
  74124. /**
  74125. * Enable or disable the render time capture
  74126. */
  74127. get captureRenderTime(): boolean;
  74128. set captureRenderTime(value: boolean);
  74129. /**
  74130. * Enable or disable the layout time capture
  74131. */
  74132. get captureLayoutTime(): boolean;
  74133. set captureLayoutTime(value: boolean);
  74134. /**
  74135. * Instantiates a new advanced dynamic texture instrumentation.
  74136. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74137. * @param texture Defines the AdvancedDynamicTexture to instrument
  74138. */
  74139. constructor(
  74140. /**
  74141. * Define the instrumented AdvancedDynamicTexture.
  74142. */
  74143. texture: AdvancedDynamicTexture);
  74144. /**
  74145. * Dispose and release associated resources.
  74146. */
  74147. dispose(): void;
  74148. }
  74149. }
  74150. declare module BABYLON.GUI {
  74151. /**
  74152. * Class used to load GUI via XML.
  74153. */
  74154. export class XmlLoader {
  74155. private _nodes;
  74156. private _nodeTypes;
  74157. private _isLoaded;
  74158. private _objectAttributes;
  74159. private _parentClass;
  74160. /**
  74161. * Create a new xml loader
  74162. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74163. */
  74164. constructor(parentClass?: null);
  74165. private _getChainElement;
  74166. private _getClassAttribute;
  74167. private _createGuiElement;
  74168. private _parseGrid;
  74169. private _parseElement;
  74170. private _prepareSourceElement;
  74171. private _parseElementsFromSource;
  74172. private _parseXml;
  74173. /**
  74174. * Gets if the loading has finished.
  74175. * @returns whether the loading has finished or not
  74176. */
  74177. isLoaded(): boolean;
  74178. /**
  74179. * Gets a loaded node / control by id.
  74180. * @param id the Controls id set in the xml
  74181. * @returns element of type Control
  74182. */
  74183. getNodeById(id: string): any;
  74184. /**
  74185. * Gets all loaded nodes / controls
  74186. * @returns Array of controls
  74187. */
  74188. getNodes(): any;
  74189. /**
  74190. * Initiates the xml layout loading
  74191. * @param xmlFile defines the xml layout to load
  74192. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74193. * @param callback defines the callback called on layout load.
  74194. */
  74195. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74196. }
  74197. }
  74198. declare module BABYLON.GUI {
  74199. /**
  74200. * Class used to create containers for controls
  74201. */
  74202. export class Container3D extends Control3D {
  74203. private _blockLayout;
  74204. /**
  74205. * Gets the list of child controls
  74206. */
  74207. protected _children: Control3D[];
  74208. /**
  74209. * Gets the list of child controls
  74210. */
  74211. get children(): Array<Control3D>;
  74212. /**
  74213. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74214. * This is helpful to optimize layout operation when adding multiple children in a row
  74215. */
  74216. get blockLayout(): boolean;
  74217. set blockLayout(value: boolean);
  74218. /**
  74219. * Creates a new container
  74220. * @param name defines the container name
  74221. */
  74222. constructor(name?: string);
  74223. /**
  74224. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74225. * @returns the current container
  74226. */
  74227. updateLayout(): Container3D;
  74228. /**
  74229. * Gets a boolean indicating if the given control is in the children of this control
  74230. * @param control defines the control to check
  74231. * @returns true if the control is in the child list
  74232. */
  74233. containsControl(control: Control3D): boolean;
  74234. /**
  74235. * Adds a control to the children of this control
  74236. * @param control defines the control to add
  74237. * @returns the current container
  74238. */
  74239. addControl(control: Control3D): Container3D;
  74240. /**
  74241. * This function will be called everytime a new control is added
  74242. */
  74243. protected _arrangeChildren(): void;
  74244. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74245. /**
  74246. * Removes a control from the children of this control
  74247. * @param control defines the control to remove
  74248. * @returns the current container
  74249. */
  74250. removeControl(control: Control3D): Container3D;
  74251. protected _getTypeName(): string;
  74252. /**
  74253. * Releases all associated resources
  74254. */
  74255. dispose(): void;
  74256. /** Control rotation will remain unchanged */
  74257. static readonly UNSET_ORIENTATION: number;
  74258. /** Control will rotate to make it look at sphere central axis */
  74259. static readonly FACEORIGIN_ORIENTATION: number;
  74260. /** Control will rotate to make it look back at sphere central axis */
  74261. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74262. /** Control will rotate to look at z axis (0, 0, 1) */
  74263. static readonly FACEFORWARD_ORIENTATION: number;
  74264. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74265. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74266. }
  74267. }
  74268. declare module BABYLON.GUI {
  74269. /**
  74270. * Class used to manage 3D user interface
  74271. * @see http://doc.babylonjs.com/how_to/gui3d
  74272. */
  74273. export class GUI3DManager implements BABYLON.IDisposable {
  74274. private _scene;
  74275. private _sceneDisposeObserver;
  74276. private _utilityLayer;
  74277. private _rootContainer;
  74278. private _pointerObserver;
  74279. private _pointerOutObserver;
  74280. /** @hidden */
  74281. _lastPickedControl: Control3D;
  74282. /** @hidden */
  74283. _lastControlOver: {
  74284. [pointerId: number]: Control3D;
  74285. };
  74286. /** @hidden */
  74287. _lastControlDown: {
  74288. [pointerId: number]: Control3D;
  74289. };
  74290. /**
  74291. * BABYLON.Observable raised when the point picked by the pointer events changed
  74292. */
  74293. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74294. /** @hidden */
  74295. _sharedMaterials: {
  74296. [key: string]: BABYLON.Material;
  74297. };
  74298. /** Gets the hosting scene */
  74299. get scene(): BABYLON.Scene;
  74300. /** Gets associated utility layer */
  74301. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74302. /**
  74303. * Creates a new GUI3DManager
  74304. * @param scene
  74305. */
  74306. constructor(scene?: BABYLON.Scene);
  74307. private _handlePointerOut;
  74308. private _doPicking;
  74309. /**
  74310. * Gets the root container
  74311. */
  74312. get rootContainer(): Container3D;
  74313. /**
  74314. * Gets a boolean indicating if the given control is in the root child list
  74315. * @param control defines the control to check
  74316. * @returns true if the control is in the root child list
  74317. */
  74318. containsControl(control: Control3D): boolean;
  74319. /**
  74320. * Adds a control to the root child list
  74321. * @param control defines the control to add
  74322. * @returns the current manager
  74323. */
  74324. addControl(control: Control3D): GUI3DManager;
  74325. /**
  74326. * Removes a control from the root child list
  74327. * @param control defines the control to remove
  74328. * @returns the current container
  74329. */
  74330. removeControl(control: Control3D): GUI3DManager;
  74331. /**
  74332. * Releases all associated resources
  74333. */
  74334. dispose(): void;
  74335. }
  74336. }
  74337. declare module BABYLON.GUI {
  74338. /**
  74339. * Class used to transport BABYLON.Vector3 information for pointer events
  74340. */
  74341. export class Vector3WithInfo extends BABYLON.Vector3 {
  74342. /** defines the current mouse button index */
  74343. buttonIndex: number;
  74344. /**
  74345. * Creates a new Vector3WithInfo
  74346. * @param source defines the vector3 data to transport
  74347. * @param buttonIndex defines the current mouse button index
  74348. */
  74349. constructor(source: BABYLON.Vector3,
  74350. /** defines the current mouse button index */
  74351. buttonIndex?: number);
  74352. }
  74353. }
  74354. declare module BABYLON.GUI {
  74355. /**
  74356. * Class used as base class for controls
  74357. */
  74358. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74359. /** Defines the control name */
  74360. name?: string | undefined;
  74361. /** @hidden */
  74362. _host: GUI3DManager;
  74363. private _node;
  74364. private _downCount;
  74365. private _enterCount;
  74366. private _downPointerIds;
  74367. private _isVisible;
  74368. /** Gets or sets the control position in world space */
  74369. get position(): BABYLON.Vector3;
  74370. set position(value: BABYLON.Vector3);
  74371. /** Gets or sets the control scaling in world space */
  74372. get scaling(): BABYLON.Vector3;
  74373. set scaling(value: BABYLON.Vector3);
  74374. /** Callback used to start pointer enter animation */
  74375. pointerEnterAnimation: () => void;
  74376. /** Callback used to start pointer out animation */
  74377. pointerOutAnimation: () => void;
  74378. /** Callback used to start pointer down animation */
  74379. pointerDownAnimation: () => void;
  74380. /** Callback used to start pointer up animation */
  74381. pointerUpAnimation: () => void;
  74382. /**
  74383. * An event triggered when the pointer move over the control
  74384. */
  74385. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74386. /**
  74387. * An event triggered when the pointer move out of the control
  74388. */
  74389. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74390. /**
  74391. * An event triggered when the pointer taps the control
  74392. */
  74393. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74394. /**
  74395. * An event triggered when pointer is up
  74396. */
  74397. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74398. /**
  74399. * An event triggered when a control is clicked on (with a mouse)
  74400. */
  74401. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74402. /**
  74403. * An event triggered when pointer enters the control
  74404. */
  74405. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74406. /**
  74407. * Gets or sets the parent container
  74408. */
  74409. parent: BABYLON.Nullable<Container3D>;
  74410. private _behaviors;
  74411. /**
  74412. * Gets the list of attached behaviors
  74413. * @see http://doc.babylonjs.com/features/behaviour
  74414. */
  74415. get behaviors(): BABYLON.Behavior<Control3D>[];
  74416. /**
  74417. * Attach a behavior to the control
  74418. * @see http://doc.babylonjs.com/features/behaviour
  74419. * @param behavior defines the behavior to attach
  74420. * @returns the current control
  74421. */
  74422. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74423. /**
  74424. * Remove an attached behavior
  74425. * @see http://doc.babylonjs.com/features/behaviour
  74426. * @param behavior defines the behavior to attach
  74427. * @returns the current control
  74428. */
  74429. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74430. /**
  74431. * Gets an attached behavior by name
  74432. * @param name defines the name of the behavior to look for
  74433. * @see http://doc.babylonjs.com/features/behaviour
  74434. * @returns null if behavior was not found else the requested behavior
  74435. */
  74436. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74437. /** Gets or sets a boolean indicating if the control is visible */
  74438. get isVisible(): boolean;
  74439. set isVisible(value: boolean);
  74440. /**
  74441. * Creates a new control
  74442. * @param name defines the control name
  74443. */
  74444. constructor(
  74445. /** Defines the control name */
  74446. name?: string | undefined);
  74447. /**
  74448. * Gets a string representing the class name
  74449. */
  74450. get typeName(): string;
  74451. /**
  74452. * Get the current class name of the control.
  74453. * @returns current class name
  74454. */
  74455. getClassName(): string;
  74456. protected _getTypeName(): string;
  74457. /**
  74458. * Gets the transform node used by this control
  74459. */
  74460. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74461. /**
  74462. * Gets the mesh used to render this control
  74463. */
  74464. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74465. /**
  74466. * Link the control as child of the given node
  74467. * @param node defines the node to link to. Use null to unlink the control
  74468. * @returns the current control
  74469. */
  74470. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74471. /** @hidden **/
  74472. _prepareNode(scene: BABYLON.Scene): void;
  74473. /**
  74474. * Node creation.
  74475. * Can be overriden by children
  74476. * @param scene defines the scene where the node must be attached
  74477. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74478. */
  74479. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74480. /**
  74481. * Affect a material to the given mesh
  74482. * @param mesh defines the mesh which will represent the control
  74483. */
  74484. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74485. /** @hidden */
  74486. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74487. /** @hidden */
  74488. _onPointerEnter(target: Control3D): boolean;
  74489. /** @hidden */
  74490. _onPointerOut(target: Control3D): void;
  74491. /** @hidden */
  74492. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74493. /** @hidden */
  74494. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74495. /** @hidden */
  74496. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74497. /** @hidden */
  74498. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74499. /** @hidden */
  74500. _disposeNode(): void;
  74501. /**
  74502. * Releases all associated resources
  74503. */
  74504. dispose(): void;
  74505. }
  74506. }
  74507. declare module BABYLON.GUI {
  74508. /**
  74509. * Class used as a root to all buttons
  74510. */
  74511. export class AbstractButton3D extends Control3D {
  74512. /**
  74513. * Creates a new button
  74514. * @param name defines the control name
  74515. */
  74516. constructor(name?: string);
  74517. protected _getTypeName(): string;
  74518. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74519. }
  74520. }
  74521. declare module BABYLON.GUI {
  74522. /**
  74523. * Class used to create a button in 3D
  74524. */
  74525. export class Button3D extends AbstractButton3D {
  74526. /** @hidden */
  74527. protected _currentMaterial: BABYLON.Material;
  74528. private _facadeTexture;
  74529. private _content;
  74530. private _contentResolution;
  74531. private _contentScaleRatio;
  74532. /**
  74533. * Gets or sets the texture resolution used to render content (512 by default)
  74534. */
  74535. get contentResolution(): BABYLON.int;
  74536. set contentResolution(value: BABYLON.int);
  74537. /**
  74538. * Gets or sets the texture scale ratio used to render content (2 by default)
  74539. */
  74540. get contentScaleRatio(): number;
  74541. set contentScaleRatio(value: number);
  74542. protected _disposeFacadeTexture(): void;
  74543. protected _resetContent(): void;
  74544. /**
  74545. * Creates a new button
  74546. * @param name defines the control name
  74547. */
  74548. constructor(name?: string);
  74549. /**
  74550. * Gets or sets the GUI 2D content used to display the button's facade
  74551. */
  74552. get content(): Control;
  74553. set content(value: Control);
  74554. /**
  74555. * Apply the facade texture (created from the content property).
  74556. * This function can be overloaded by child classes
  74557. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74558. */
  74559. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74560. protected _getTypeName(): string;
  74561. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74562. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74563. /**
  74564. * Releases all associated resources
  74565. */
  74566. dispose(): void;
  74567. }
  74568. }
  74569. declare module BABYLON.GUI {
  74570. /**
  74571. * Abstract class used to create a container panel deployed on the surface of a volume
  74572. */
  74573. export abstract class VolumeBasedPanel extends Container3D {
  74574. private _columns;
  74575. private _rows;
  74576. private _rowThenColum;
  74577. private _orientation;
  74578. protected _cellWidth: number;
  74579. protected _cellHeight: number;
  74580. /**
  74581. * Gets or sets the distance between elements
  74582. */
  74583. margin: number;
  74584. /**
  74585. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74586. * | Value | Type | Description |
  74587. * | ----- | ----------------------------------- | ----------- |
  74588. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74589. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74590. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74591. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74592. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74593. */
  74594. get orientation(): number;
  74595. set orientation(value: number);
  74596. /**
  74597. * Gets or sets the number of columns requested (10 by default).
  74598. * The panel will automatically compute the number of rows based on number of child controls.
  74599. */
  74600. get columns(): BABYLON.int;
  74601. set columns(value: BABYLON.int);
  74602. /**
  74603. * Gets or sets a the number of rows requested.
  74604. * The panel will automatically compute the number of columns based on number of child controls.
  74605. */
  74606. get rows(): BABYLON.int;
  74607. set rows(value: BABYLON.int);
  74608. /**
  74609. * Creates new VolumeBasedPanel
  74610. */
  74611. constructor();
  74612. protected _arrangeChildren(): void;
  74613. /** Child classes must implement this function to provide correct control positioning */
  74614. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74615. /** Child classes can implement this function to provide additional processing */
  74616. protected _finalProcessing(): void;
  74617. }
  74618. }
  74619. declare module BABYLON.GUI {
  74620. /**
  74621. * Class used to create a container panel deployed on the surface of a cylinder
  74622. */
  74623. export class CylinderPanel extends VolumeBasedPanel {
  74624. private _radius;
  74625. /**
  74626. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74627. */
  74628. get radius(): BABYLON.float;
  74629. set radius(value: BABYLON.float);
  74630. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74631. private _cylindricalMapping;
  74632. }
  74633. }
  74634. declare module BABYLON.GUI {
  74635. /** @hidden */
  74636. export var fluentVertexShader: {
  74637. name: string;
  74638. shader: string;
  74639. };
  74640. }
  74641. declare module BABYLON.GUI {
  74642. /** @hidden */
  74643. export var fluentPixelShader: {
  74644. name: string;
  74645. shader: string;
  74646. };
  74647. }
  74648. declare module BABYLON.GUI {
  74649. /** @hidden */
  74650. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74651. INNERGLOW: boolean;
  74652. BORDER: boolean;
  74653. HOVERLIGHT: boolean;
  74654. TEXTURE: boolean;
  74655. constructor();
  74656. }
  74657. /**
  74658. * Class used to render controls with fluent desgin
  74659. */
  74660. export class FluentMaterial extends BABYLON.PushMaterial {
  74661. /**
  74662. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74663. */
  74664. innerGlowColorIntensity: number;
  74665. /**
  74666. * Gets or sets the inner glow color (white by default)
  74667. */
  74668. innerGlowColor: BABYLON.Color3;
  74669. /**
  74670. * Gets or sets alpha value (default is 1.0)
  74671. */
  74672. alpha: number;
  74673. /**
  74674. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74675. */
  74676. albedoColor: BABYLON.Color3;
  74677. /**
  74678. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74679. */
  74680. renderBorders: boolean;
  74681. /**
  74682. * Gets or sets border width (default is 0.5)
  74683. */
  74684. borderWidth: number;
  74685. /**
  74686. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74687. */
  74688. edgeSmoothingValue: number;
  74689. /**
  74690. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74691. */
  74692. borderMinValue: number;
  74693. /**
  74694. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74695. */
  74696. renderHoverLight: boolean;
  74697. /**
  74698. * Gets or sets the radius used to render the hover light (default is 1.0)
  74699. */
  74700. hoverRadius: number;
  74701. /**
  74702. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74703. */
  74704. hoverColor: BABYLON.Color4;
  74705. /**
  74706. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74707. */
  74708. hoverPosition: BABYLON.Vector3;
  74709. private _albedoTexture;
  74710. /** Gets or sets the texture to use for albedo color */
  74711. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74712. /**
  74713. * Creates a new Fluent material
  74714. * @param name defines the name of the material
  74715. * @param scene defines the hosting scene
  74716. */
  74717. constructor(name: string, scene: BABYLON.Scene);
  74718. needAlphaBlending(): boolean;
  74719. needAlphaTesting(): boolean;
  74720. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74721. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74722. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74723. getActiveTextures(): BABYLON.BaseTexture[];
  74724. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74725. dispose(forceDisposeEffect?: boolean): void;
  74726. clone(name: string): FluentMaterial;
  74727. serialize(): any;
  74728. getClassName(): string;
  74729. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74730. }
  74731. }
  74732. declare module BABYLON.GUI {
  74733. /**
  74734. * Class used to create a holographic button in 3D
  74735. */
  74736. export class HolographicButton extends Button3D {
  74737. private _backPlate;
  74738. private _textPlate;
  74739. private _frontPlate;
  74740. private _text;
  74741. private _imageUrl;
  74742. private _shareMaterials;
  74743. private _frontMaterial;
  74744. private _backMaterial;
  74745. private _plateMaterial;
  74746. private _pickedPointObserver;
  74747. private _tooltipFade;
  74748. private _tooltipTextBlock;
  74749. private _tooltipTexture;
  74750. private _tooltipMesh;
  74751. private _tooltipHoverObserver;
  74752. private _tooltipOutObserver;
  74753. private _disposeTooltip;
  74754. /**
  74755. * Rendering ground id of all the mesh in the button
  74756. */
  74757. set renderingGroupId(id: number);
  74758. get renderingGroupId(): number;
  74759. /**
  74760. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74761. */
  74762. set tooltipText(text: BABYLON.Nullable<string>);
  74763. get tooltipText(): BABYLON.Nullable<string>;
  74764. /**
  74765. * Gets or sets text for the button
  74766. */
  74767. get text(): string;
  74768. set text(value: string);
  74769. /**
  74770. * Gets or sets the image url for the button
  74771. */
  74772. get imageUrl(): string;
  74773. set imageUrl(value: string);
  74774. /**
  74775. * Gets the back material used by this button
  74776. */
  74777. get backMaterial(): FluentMaterial;
  74778. /**
  74779. * Gets the front material used by this button
  74780. */
  74781. get frontMaterial(): FluentMaterial;
  74782. /**
  74783. * Gets the plate material used by this button
  74784. */
  74785. get plateMaterial(): BABYLON.StandardMaterial;
  74786. /**
  74787. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74788. */
  74789. get shareMaterials(): boolean;
  74790. /**
  74791. * Creates a new button
  74792. * @param name defines the control name
  74793. */
  74794. constructor(name?: string, shareMaterials?: boolean);
  74795. protected _getTypeName(): string;
  74796. private _rebuildContent;
  74797. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74798. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74799. private _createBackMaterial;
  74800. private _createFrontMaterial;
  74801. private _createPlateMaterial;
  74802. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74803. /**
  74804. * Releases all associated resources
  74805. */
  74806. dispose(): void;
  74807. }
  74808. }
  74809. declare module BABYLON.GUI {
  74810. /**
  74811. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74812. */
  74813. export class MeshButton3D extends Button3D {
  74814. /** @hidden */
  74815. protected _currentMesh: BABYLON.Mesh;
  74816. /**
  74817. * Creates a new 3D button based on a mesh
  74818. * @param mesh mesh to become a 3D button
  74819. * @param name defines the control name
  74820. */
  74821. constructor(mesh: BABYLON.Mesh, name?: string);
  74822. protected _getTypeName(): string;
  74823. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74824. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74825. }
  74826. }
  74827. declare module BABYLON.GUI {
  74828. /**
  74829. * Class used to create a container panel deployed on the surface of a plane
  74830. */
  74831. export class PlanePanel extends VolumeBasedPanel {
  74832. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74833. }
  74834. }
  74835. declare module BABYLON.GUI {
  74836. /**
  74837. * Class used to create a container panel where items get randomized planar mapping
  74838. */
  74839. export class ScatterPanel extends VolumeBasedPanel {
  74840. private _iteration;
  74841. /**
  74842. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74843. */
  74844. get iteration(): BABYLON.float;
  74845. set iteration(value: BABYLON.float);
  74846. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74847. private _scatterMapping;
  74848. protected _finalProcessing(): void;
  74849. }
  74850. }
  74851. declare module BABYLON.GUI {
  74852. /**
  74853. * Class used to create a container panel deployed on the surface of a sphere
  74854. */
  74855. export class SpherePanel extends VolumeBasedPanel {
  74856. private _radius;
  74857. /**
  74858. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74859. */
  74860. get radius(): BABYLON.float;
  74861. set radius(value: BABYLON.float);
  74862. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74863. private _sphericalMapping;
  74864. }
  74865. }
  74866. declare module BABYLON.GUI {
  74867. /**
  74868. * Class used to create a stack panel in 3D on XY plane
  74869. */
  74870. export class StackPanel3D extends Container3D {
  74871. private _isVertical;
  74872. /**
  74873. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74874. */
  74875. get isVertical(): boolean;
  74876. set isVertical(value: boolean);
  74877. /**
  74878. * Gets or sets the distance between elements
  74879. */
  74880. margin: number;
  74881. /**
  74882. * Creates new StackPanel
  74883. * @param isVertical
  74884. */
  74885. constructor(isVertical?: boolean);
  74886. protected _arrangeChildren(): void;
  74887. }
  74888. }
  74889. declare module BABYLON {
  74890. /**
  74891. * Configuration for glTF validation
  74892. */
  74893. export interface IGLTFValidationConfiguration {
  74894. /**
  74895. * The url of the glTF validator.
  74896. */
  74897. url: string;
  74898. }
  74899. /**
  74900. * glTF validation
  74901. */
  74902. export class GLTFValidation {
  74903. /**
  74904. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74905. */
  74906. static Configuration: IGLTFValidationConfiguration;
  74907. private static _LoadScriptPromise;
  74908. /**
  74909. * Validate a glTF asset using the glTF-Validator.
  74910. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74911. * @param rootUrl The root url for the glTF
  74912. * @param fileName The file name for the glTF
  74913. * @param getExternalResource The callback to get external resources for the glTF validator
  74914. * @returns A promise that resolves with the glTF validation results once complete
  74915. */
  74916. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74917. }
  74918. }
  74919. declare module BABYLON {
  74920. /**
  74921. * Mode that determines the coordinate system to use.
  74922. */
  74923. export enum GLTFLoaderCoordinateSystemMode {
  74924. /**
  74925. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74926. */
  74927. AUTO = 0,
  74928. /**
  74929. * Sets the useRightHandedSystem flag on the scene.
  74930. */
  74931. FORCE_RIGHT_HANDED = 1
  74932. }
  74933. /**
  74934. * Mode that determines what animations will start.
  74935. */
  74936. export enum GLTFLoaderAnimationStartMode {
  74937. /**
  74938. * No animation will start.
  74939. */
  74940. NONE = 0,
  74941. /**
  74942. * The first animation will start.
  74943. */
  74944. FIRST = 1,
  74945. /**
  74946. * All animations will start.
  74947. */
  74948. ALL = 2
  74949. }
  74950. /**
  74951. * Interface that contains the data for the glTF asset.
  74952. */
  74953. export interface IGLTFLoaderData {
  74954. /**
  74955. * The object that represents the glTF JSON.
  74956. */
  74957. json: Object;
  74958. /**
  74959. * The BIN chunk of a binary glTF.
  74960. */
  74961. bin: Nullable<IDataBuffer>;
  74962. }
  74963. /**
  74964. * Interface for extending the loader.
  74965. */
  74966. export interface IGLTFLoaderExtension {
  74967. /**
  74968. * The name of this extension.
  74969. */
  74970. readonly name: string;
  74971. /**
  74972. * Defines whether this extension is enabled.
  74973. */
  74974. enabled: boolean;
  74975. /**
  74976. * Defines the order of this extension.
  74977. * The loader sorts the extensions using these values when loading.
  74978. */
  74979. order?: number;
  74980. }
  74981. /**
  74982. * Loader state.
  74983. */
  74984. export enum GLTFLoaderState {
  74985. /**
  74986. * The asset is loading.
  74987. */
  74988. LOADING = 0,
  74989. /**
  74990. * The asset is ready for rendering.
  74991. */
  74992. READY = 1,
  74993. /**
  74994. * The asset is completely loaded.
  74995. */
  74996. COMPLETE = 2
  74997. }
  74998. /** @hidden */
  74999. export interface IImportMeshAsyncOutput {
  75000. meshes: AbstractMesh[];
  75001. particleSystems: IParticleSystem[];
  75002. skeletons: Skeleton[];
  75003. animationGroups: AnimationGroup[];
  75004. lights: Light[];
  75005. transformNodes: TransformNode[];
  75006. }
  75007. /** @hidden */
  75008. export interface IGLTFLoader extends IDisposable {
  75009. readonly state: Nullable<GLTFLoaderState>;
  75010. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75011. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75012. }
  75013. /**
  75014. * File loader for loading glTF files into a scene.
  75015. */
  75016. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75017. /** @hidden */
  75018. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75019. /** @hidden */
  75020. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75021. /**
  75022. * Raised when the asset has been parsed
  75023. */
  75024. onParsedObservable: Observable<IGLTFLoaderData>;
  75025. private _onParsedObserver;
  75026. /**
  75027. * Raised when the asset has been parsed
  75028. */
  75029. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75030. /**
  75031. * 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.
  75032. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75033. * Defaults to true.
  75034. * @hidden
  75035. */
  75036. static IncrementalLoading: boolean;
  75037. /**
  75038. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75039. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75040. * @hidden
  75041. */
  75042. static HomogeneousCoordinates: boolean;
  75043. /**
  75044. * The coordinate system mode. Defaults to AUTO.
  75045. */
  75046. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75047. /**
  75048. * The animation start mode. Defaults to FIRST.
  75049. */
  75050. animationStartMode: GLTFLoaderAnimationStartMode;
  75051. /**
  75052. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75053. */
  75054. compileMaterials: boolean;
  75055. /**
  75056. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75057. */
  75058. useClipPlane: boolean;
  75059. /**
  75060. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75061. */
  75062. compileShadowGenerators: boolean;
  75063. /**
  75064. * Defines if the Alpha blended materials are only applied as coverage.
  75065. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75066. * If true, no extra effects are applied to transparent pixels.
  75067. */
  75068. transparencyAsCoverage: boolean;
  75069. /**
  75070. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75071. * Enabling will disable offline support and glTF validator.
  75072. * Defaults to false.
  75073. */
  75074. useRangeRequests: boolean;
  75075. /**
  75076. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75077. */
  75078. createInstances: boolean;
  75079. /**
  75080. * Function called before loading a url referenced by the asset.
  75081. */
  75082. preprocessUrlAsync: (url: string) => Promise<string>;
  75083. /**
  75084. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75085. */
  75086. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75087. private _onMeshLoadedObserver;
  75088. /**
  75089. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75090. */
  75091. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75092. /**
  75093. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75094. */
  75095. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75096. private _onTextureLoadedObserver;
  75097. /**
  75098. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75099. */
  75100. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75101. /**
  75102. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75103. */
  75104. readonly onMaterialLoadedObservable: Observable<Material>;
  75105. private _onMaterialLoadedObserver;
  75106. /**
  75107. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75108. */
  75109. set onMaterialLoaded(callback: (material: Material) => void);
  75110. /**
  75111. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75112. */
  75113. readonly onCameraLoadedObservable: Observable<Camera>;
  75114. private _onCameraLoadedObserver;
  75115. /**
  75116. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75117. */
  75118. set onCameraLoaded(callback: (camera: Camera) => void);
  75119. /**
  75120. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75121. * For assets with LODs, raised when all of the LODs are complete.
  75122. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75123. */
  75124. readonly onCompleteObservable: Observable<void>;
  75125. private _onCompleteObserver;
  75126. /**
  75127. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75128. * For assets with LODs, raised when all of the LODs are complete.
  75129. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75130. */
  75131. set onComplete(callback: () => void);
  75132. /**
  75133. * Observable raised when an error occurs.
  75134. */
  75135. readonly onErrorObservable: Observable<any>;
  75136. private _onErrorObserver;
  75137. /**
  75138. * Callback raised when an error occurs.
  75139. */
  75140. set onError(callback: (reason: any) => void);
  75141. /**
  75142. * Observable raised after the loader is disposed.
  75143. */
  75144. readonly onDisposeObservable: Observable<void>;
  75145. private _onDisposeObserver;
  75146. /**
  75147. * Callback raised after the loader is disposed.
  75148. */
  75149. set onDispose(callback: () => void);
  75150. /**
  75151. * Observable raised after a loader extension is created.
  75152. * Set additional options for a loader extension in this event.
  75153. */
  75154. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75155. private _onExtensionLoadedObserver;
  75156. /**
  75157. * Callback raised after a loader extension is created.
  75158. */
  75159. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75160. /**
  75161. * Defines if the loader logging is enabled.
  75162. */
  75163. get loggingEnabled(): boolean;
  75164. set loggingEnabled(value: boolean);
  75165. /**
  75166. * Defines if the loader should capture performance counters.
  75167. */
  75168. get capturePerformanceCounters(): boolean;
  75169. set capturePerformanceCounters(value: boolean);
  75170. /**
  75171. * Defines if the loader should validate the asset.
  75172. */
  75173. validate: boolean;
  75174. /**
  75175. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75176. */
  75177. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75178. private _onValidatedObserver;
  75179. /**
  75180. * Callback raised after a loader extension is created.
  75181. */
  75182. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75183. private _loader;
  75184. /**
  75185. * Name of the loader ("gltf")
  75186. */
  75187. name: string;
  75188. /** @hidden */
  75189. extensions: ISceneLoaderPluginExtensions;
  75190. /**
  75191. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75192. */
  75193. dispose(): void;
  75194. /** @hidden */
  75195. _clear(): void;
  75196. /** @hidden */
  75197. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75198. /** @hidden */
  75199. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75200. /** @hidden */
  75201. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75202. meshes: AbstractMesh[];
  75203. particleSystems: IParticleSystem[];
  75204. skeletons: Skeleton[];
  75205. animationGroups: AnimationGroup[];
  75206. }>;
  75207. /** @hidden */
  75208. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75209. /** @hidden */
  75210. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75211. /** @hidden */
  75212. canDirectLoad(data: string): boolean;
  75213. /** @hidden */
  75214. directLoad(scene: Scene, data: string): any;
  75215. /**
  75216. * The callback that allows custom handling of the root url based on the response url.
  75217. * @param rootUrl the original root url
  75218. * @param responseURL the response url if available
  75219. * @returns the new root url
  75220. */
  75221. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75222. /** @hidden */
  75223. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75224. /**
  75225. * The loader state or null if the loader is not active.
  75226. */
  75227. get loaderState(): Nullable<GLTFLoaderState>;
  75228. /**
  75229. * Returns a promise that resolves when the asset is completely loaded.
  75230. * @returns a promise that resolves when the asset is completely loaded.
  75231. */
  75232. whenCompleteAsync(): Promise<void>;
  75233. private _validate;
  75234. private _getLoader;
  75235. private _parseJson;
  75236. private _unpackBinaryAsync;
  75237. private _unpackBinaryV1Async;
  75238. private _unpackBinaryV2Async;
  75239. private static _parseVersion;
  75240. private static _compareVersion;
  75241. private static readonly _logSpaces;
  75242. private _logIndentLevel;
  75243. private _loggingEnabled;
  75244. /** @hidden */
  75245. _log: (message: string) => void;
  75246. /** @hidden */
  75247. _logOpen(message: string): void;
  75248. /** @hidden */
  75249. _logClose(): void;
  75250. private _logEnabled;
  75251. private _logDisabled;
  75252. private _capturePerformanceCounters;
  75253. /** @hidden */
  75254. _startPerformanceCounter: (counterName: string) => void;
  75255. /** @hidden */
  75256. _endPerformanceCounter: (counterName: string) => void;
  75257. private _startPerformanceCounterEnabled;
  75258. private _startPerformanceCounterDisabled;
  75259. private _endPerformanceCounterEnabled;
  75260. private _endPerformanceCounterDisabled;
  75261. }
  75262. }
  75263. declare module BABYLON.GLTF1 {
  75264. /**
  75265. * Enums
  75266. * @hidden
  75267. */
  75268. export enum EComponentType {
  75269. BYTE = 5120,
  75270. UNSIGNED_BYTE = 5121,
  75271. SHORT = 5122,
  75272. UNSIGNED_SHORT = 5123,
  75273. FLOAT = 5126
  75274. }
  75275. /** @hidden */
  75276. export enum EShaderType {
  75277. FRAGMENT = 35632,
  75278. VERTEX = 35633
  75279. }
  75280. /** @hidden */
  75281. export enum EParameterType {
  75282. BYTE = 5120,
  75283. UNSIGNED_BYTE = 5121,
  75284. SHORT = 5122,
  75285. UNSIGNED_SHORT = 5123,
  75286. INT = 5124,
  75287. UNSIGNED_INT = 5125,
  75288. FLOAT = 5126,
  75289. FLOAT_VEC2 = 35664,
  75290. FLOAT_VEC3 = 35665,
  75291. FLOAT_VEC4 = 35666,
  75292. INT_VEC2 = 35667,
  75293. INT_VEC3 = 35668,
  75294. INT_VEC4 = 35669,
  75295. BOOL = 35670,
  75296. BOOL_VEC2 = 35671,
  75297. BOOL_VEC3 = 35672,
  75298. BOOL_VEC4 = 35673,
  75299. FLOAT_MAT2 = 35674,
  75300. FLOAT_MAT3 = 35675,
  75301. FLOAT_MAT4 = 35676,
  75302. SAMPLER_2D = 35678
  75303. }
  75304. /** @hidden */
  75305. export enum ETextureWrapMode {
  75306. CLAMP_TO_EDGE = 33071,
  75307. MIRRORED_REPEAT = 33648,
  75308. REPEAT = 10497
  75309. }
  75310. /** @hidden */
  75311. export enum ETextureFilterType {
  75312. NEAREST = 9728,
  75313. LINEAR = 9728,
  75314. NEAREST_MIPMAP_NEAREST = 9984,
  75315. LINEAR_MIPMAP_NEAREST = 9985,
  75316. NEAREST_MIPMAP_LINEAR = 9986,
  75317. LINEAR_MIPMAP_LINEAR = 9987
  75318. }
  75319. /** @hidden */
  75320. export enum ETextureFormat {
  75321. ALPHA = 6406,
  75322. RGB = 6407,
  75323. RGBA = 6408,
  75324. LUMINANCE = 6409,
  75325. LUMINANCE_ALPHA = 6410
  75326. }
  75327. /** @hidden */
  75328. export enum ECullingType {
  75329. FRONT = 1028,
  75330. BACK = 1029,
  75331. FRONT_AND_BACK = 1032
  75332. }
  75333. /** @hidden */
  75334. export enum EBlendingFunction {
  75335. ZERO = 0,
  75336. ONE = 1,
  75337. SRC_COLOR = 768,
  75338. ONE_MINUS_SRC_COLOR = 769,
  75339. DST_COLOR = 774,
  75340. ONE_MINUS_DST_COLOR = 775,
  75341. SRC_ALPHA = 770,
  75342. ONE_MINUS_SRC_ALPHA = 771,
  75343. DST_ALPHA = 772,
  75344. ONE_MINUS_DST_ALPHA = 773,
  75345. CONSTANT_COLOR = 32769,
  75346. ONE_MINUS_CONSTANT_COLOR = 32770,
  75347. CONSTANT_ALPHA = 32771,
  75348. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75349. SRC_ALPHA_SATURATE = 776
  75350. }
  75351. /** @hidden */
  75352. export interface IGLTFProperty {
  75353. extensions?: {
  75354. [key: string]: any;
  75355. };
  75356. extras?: Object;
  75357. }
  75358. /** @hidden */
  75359. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75360. name?: string;
  75361. }
  75362. /** @hidden */
  75363. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75364. bufferView: string;
  75365. byteOffset: number;
  75366. byteStride: number;
  75367. count: number;
  75368. type: string;
  75369. componentType: EComponentType;
  75370. max?: number[];
  75371. min?: number[];
  75372. name?: string;
  75373. }
  75374. /** @hidden */
  75375. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75376. buffer: string;
  75377. byteOffset: number;
  75378. byteLength: number;
  75379. byteStride: number;
  75380. target?: number;
  75381. }
  75382. /** @hidden */
  75383. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75384. uri: string;
  75385. byteLength?: number;
  75386. type?: string;
  75387. }
  75388. /** @hidden */
  75389. export interface IGLTFShader extends IGLTFChildRootProperty {
  75390. uri: string;
  75391. type: EShaderType;
  75392. }
  75393. /** @hidden */
  75394. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75395. attributes: string[];
  75396. fragmentShader: string;
  75397. vertexShader: string;
  75398. }
  75399. /** @hidden */
  75400. export interface IGLTFTechniqueParameter {
  75401. type: number;
  75402. count?: number;
  75403. semantic?: string;
  75404. node?: string;
  75405. value?: number | boolean | string | Array<any>;
  75406. source?: string;
  75407. babylonValue?: any;
  75408. }
  75409. /** @hidden */
  75410. export interface IGLTFTechniqueCommonProfile {
  75411. lightingModel: string;
  75412. texcoordBindings: Object;
  75413. parameters?: Array<any>;
  75414. }
  75415. /** @hidden */
  75416. export interface IGLTFTechniqueStatesFunctions {
  75417. blendColor?: number[];
  75418. blendEquationSeparate?: number[];
  75419. blendFuncSeparate?: number[];
  75420. colorMask: boolean[];
  75421. cullFace: number[];
  75422. }
  75423. /** @hidden */
  75424. export interface IGLTFTechniqueStates {
  75425. enable: number[];
  75426. functions: IGLTFTechniqueStatesFunctions;
  75427. }
  75428. /** @hidden */
  75429. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75430. parameters: {
  75431. [key: string]: IGLTFTechniqueParameter;
  75432. };
  75433. program: string;
  75434. attributes: {
  75435. [key: string]: string;
  75436. };
  75437. uniforms: {
  75438. [key: string]: string;
  75439. };
  75440. states: IGLTFTechniqueStates;
  75441. }
  75442. /** @hidden */
  75443. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75444. technique?: string;
  75445. values: string[];
  75446. }
  75447. /** @hidden */
  75448. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75449. attributes: {
  75450. [key: string]: string;
  75451. };
  75452. indices: string;
  75453. material: string;
  75454. mode?: number;
  75455. }
  75456. /** @hidden */
  75457. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75458. primitives: IGLTFMeshPrimitive[];
  75459. }
  75460. /** @hidden */
  75461. export interface IGLTFImage extends IGLTFChildRootProperty {
  75462. uri: string;
  75463. }
  75464. /** @hidden */
  75465. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75466. magFilter?: number;
  75467. minFilter?: number;
  75468. wrapS?: number;
  75469. wrapT?: number;
  75470. }
  75471. /** @hidden */
  75472. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75473. sampler: string;
  75474. source: string;
  75475. format?: ETextureFormat;
  75476. internalFormat?: ETextureFormat;
  75477. target?: number;
  75478. type?: number;
  75479. babylonTexture?: Texture;
  75480. }
  75481. /** @hidden */
  75482. export interface IGLTFAmbienLight {
  75483. color?: number[];
  75484. }
  75485. /** @hidden */
  75486. export interface IGLTFDirectionalLight {
  75487. color?: number[];
  75488. }
  75489. /** @hidden */
  75490. export interface IGLTFPointLight {
  75491. color?: number[];
  75492. constantAttenuation?: number;
  75493. linearAttenuation?: number;
  75494. quadraticAttenuation?: number;
  75495. }
  75496. /** @hidden */
  75497. export interface IGLTFSpotLight {
  75498. color?: number[];
  75499. constantAttenuation?: number;
  75500. fallOfAngle?: number;
  75501. fallOffExponent?: number;
  75502. linearAttenuation?: number;
  75503. quadraticAttenuation?: number;
  75504. }
  75505. /** @hidden */
  75506. export interface IGLTFLight extends IGLTFChildRootProperty {
  75507. type: string;
  75508. }
  75509. /** @hidden */
  75510. export interface IGLTFCameraOrthographic {
  75511. xmag: number;
  75512. ymag: number;
  75513. zfar: number;
  75514. znear: number;
  75515. }
  75516. /** @hidden */
  75517. export interface IGLTFCameraPerspective {
  75518. aspectRatio: number;
  75519. yfov: number;
  75520. zfar: number;
  75521. znear: number;
  75522. }
  75523. /** @hidden */
  75524. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75525. type: string;
  75526. }
  75527. /** @hidden */
  75528. export interface IGLTFAnimationChannelTarget {
  75529. id: string;
  75530. path: string;
  75531. }
  75532. /** @hidden */
  75533. export interface IGLTFAnimationChannel {
  75534. sampler: string;
  75535. target: IGLTFAnimationChannelTarget;
  75536. }
  75537. /** @hidden */
  75538. export interface IGLTFAnimationSampler {
  75539. input: string;
  75540. output: string;
  75541. interpolation?: string;
  75542. }
  75543. /** @hidden */
  75544. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75545. channels?: IGLTFAnimationChannel[];
  75546. parameters?: {
  75547. [key: string]: string;
  75548. };
  75549. samplers?: {
  75550. [key: string]: IGLTFAnimationSampler;
  75551. };
  75552. }
  75553. /** @hidden */
  75554. export interface IGLTFNodeInstanceSkin {
  75555. skeletons: string[];
  75556. skin: string;
  75557. meshes: string[];
  75558. }
  75559. /** @hidden */
  75560. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75561. bindShapeMatrix: number[];
  75562. inverseBindMatrices: string;
  75563. jointNames: string[];
  75564. babylonSkeleton?: Skeleton;
  75565. }
  75566. /** @hidden */
  75567. export interface IGLTFNode extends IGLTFChildRootProperty {
  75568. camera?: string;
  75569. children: string[];
  75570. skin?: string;
  75571. jointName?: string;
  75572. light?: string;
  75573. matrix: number[];
  75574. mesh?: string;
  75575. meshes?: string[];
  75576. rotation?: number[];
  75577. scale?: number[];
  75578. translation?: number[];
  75579. babylonNode?: Node;
  75580. }
  75581. /** @hidden */
  75582. export interface IGLTFScene extends IGLTFChildRootProperty {
  75583. nodes: string[];
  75584. }
  75585. /** @hidden */
  75586. export interface IGLTFRuntime {
  75587. extensions: {
  75588. [key: string]: any;
  75589. };
  75590. accessors: {
  75591. [key: string]: IGLTFAccessor;
  75592. };
  75593. buffers: {
  75594. [key: string]: IGLTFBuffer;
  75595. };
  75596. bufferViews: {
  75597. [key: string]: IGLTFBufferView;
  75598. };
  75599. meshes: {
  75600. [key: string]: IGLTFMesh;
  75601. };
  75602. lights: {
  75603. [key: string]: IGLTFLight;
  75604. };
  75605. cameras: {
  75606. [key: string]: IGLTFCamera;
  75607. };
  75608. nodes: {
  75609. [key: string]: IGLTFNode;
  75610. };
  75611. images: {
  75612. [key: string]: IGLTFImage;
  75613. };
  75614. textures: {
  75615. [key: string]: IGLTFTexture;
  75616. };
  75617. shaders: {
  75618. [key: string]: IGLTFShader;
  75619. };
  75620. programs: {
  75621. [key: string]: IGLTFProgram;
  75622. };
  75623. samplers: {
  75624. [key: string]: IGLTFSampler;
  75625. };
  75626. techniques: {
  75627. [key: string]: IGLTFTechnique;
  75628. };
  75629. materials: {
  75630. [key: string]: IGLTFMaterial;
  75631. };
  75632. animations: {
  75633. [key: string]: IGLTFAnimation;
  75634. };
  75635. skins: {
  75636. [key: string]: IGLTFSkins;
  75637. };
  75638. currentScene?: Object;
  75639. scenes: {
  75640. [key: string]: IGLTFScene;
  75641. };
  75642. extensionsUsed: string[];
  75643. extensionsRequired?: string[];
  75644. buffersCount: number;
  75645. shaderscount: number;
  75646. scene: Scene;
  75647. rootUrl: string;
  75648. loadedBufferCount: number;
  75649. loadedBufferViews: {
  75650. [name: string]: ArrayBufferView;
  75651. };
  75652. loadedShaderCount: number;
  75653. importOnlyMeshes: boolean;
  75654. importMeshesNames?: string[];
  75655. dummyNodes: Node[];
  75656. forAssetContainer: boolean;
  75657. }
  75658. /** @hidden */
  75659. export interface INodeToRoot {
  75660. bone: Bone;
  75661. node: IGLTFNode;
  75662. id: string;
  75663. }
  75664. /** @hidden */
  75665. export interface IJointNode {
  75666. node: IGLTFNode;
  75667. id: string;
  75668. }
  75669. }
  75670. declare module BABYLON.GLTF1 {
  75671. /**
  75672. * Utils functions for GLTF
  75673. * @hidden
  75674. */
  75675. export class GLTFUtils {
  75676. /**
  75677. * Sets the given "parameter" matrix
  75678. * @param scene: the Scene object
  75679. * @param source: the source node where to pick the matrix
  75680. * @param parameter: the GLTF technique parameter
  75681. * @param uniformName: the name of the shader's uniform
  75682. * @param shaderMaterial: the shader material
  75683. */
  75684. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75685. /**
  75686. * Sets the given "parameter" matrix
  75687. * @param shaderMaterial: the shader material
  75688. * @param uniform: the name of the shader's uniform
  75689. * @param value: the value of the uniform
  75690. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75691. */
  75692. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75693. /**
  75694. * Returns the wrap mode of the texture
  75695. * @param mode: the mode value
  75696. */
  75697. static GetWrapMode(mode: number): number;
  75698. /**
  75699. * Returns the byte stride giving an accessor
  75700. * @param accessor: the GLTF accessor objet
  75701. */
  75702. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75703. /**
  75704. * Returns the texture filter mode giving a mode value
  75705. * @param mode: the filter mode value
  75706. */
  75707. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75708. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75709. /**
  75710. * Returns a buffer from its accessor
  75711. * @param gltfRuntime: the GLTF runtime
  75712. * @param accessor: the GLTF accessor
  75713. */
  75714. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75715. /**
  75716. * Decodes a buffer view into a string
  75717. * @param view: the buffer view
  75718. */
  75719. static DecodeBufferToText(view: ArrayBufferView): string;
  75720. /**
  75721. * Returns the default material of gltf. Related to
  75722. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75723. * @param scene: the Babylon.js scene
  75724. */
  75725. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75726. private static _DefaultMaterial;
  75727. }
  75728. }
  75729. declare module BABYLON.GLTF1 {
  75730. /**
  75731. * Implementation of the base glTF spec
  75732. * @hidden
  75733. */
  75734. export class GLTFLoaderBase {
  75735. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75736. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75737. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75738. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75739. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75740. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75741. }
  75742. /**
  75743. * glTF V1 Loader
  75744. * @hidden
  75745. */
  75746. export class GLTFLoader implements IGLTFLoader {
  75747. static Extensions: {
  75748. [name: string]: GLTFLoaderExtension;
  75749. };
  75750. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75751. state: Nullable<GLTFLoaderState>;
  75752. dispose(): void;
  75753. private _importMeshAsync;
  75754. /**
  75755. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75756. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75757. * @param scene the scene the meshes should be added to
  75758. * @param forAssetContainer defines if the entities must be stored in the scene
  75759. * @param data gltf data containing information of the meshes in a loaded file
  75760. * @param rootUrl root url to load from
  75761. * @param onProgress event that fires when loading progress has occured
  75762. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75763. */
  75764. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75765. private _loadAsync;
  75766. /**
  75767. * Imports all objects from a loaded gltf file and adds them to the scene
  75768. * @param scene the scene the objects should be added to
  75769. * @param data gltf data containing information of the meshes in a loaded file
  75770. * @param rootUrl root url to load from
  75771. * @param onProgress event that fires when loading progress has occured
  75772. * @returns a promise which completes when objects have been loaded to the scene
  75773. */
  75774. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75775. private _loadShadersAsync;
  75776. private _loadBuffersAsync;
  75777. private _createNodes;
  75778. }
  75779. /** @hidden */
  75780. export abstract class GLTFLoaderExtension {
  75781. private _name;
  75782. constructor(name: string);
  75783. get name(): string;
  75784. /**
  75785. * Defines an override for loading the runtime
  75786. * Return true to stop further extensions from loading the runtime
  75787. */
  75788. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75789. /**
  75790. * Defines an onverride for creating gltf runtime
  75791. * Return true to stop further extensions from creating the runtime
  75792. */
  75793. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75794. /**
  75795. * Defines an override for loading buffers
  75796. * Return true to stop further extensions from loading this buffer
  75797. */
  75798. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75799. /**
  75800. * Defines an override for loading texture buffers
  75801. * Return true to stop further extensions from loading this texture data
  75802. */
  75803. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75804. /**
  75805. * Defines an override for creating textures
  75806. * Return true to stop further extensions from loading this texture
  75807. */
  75808. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75809. /**
  75810. * Defines an override for loading shader strings
  75811. * Return true to stop further extensions from loading this shader data
  75812. */
  75813. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75814. /**
  75815. * Defines an override for loading materials
  75816. * Return true to stop further extensions from loading this material
  75817. */
  75818. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75819. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75820. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75821. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75822. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75823. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75824. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75825. private static LoadTextureBufferAsync;
  75826. private static CreateTextureAsync;
  75827. private static ApplyExtensions;
  75828. }
  75829. }
  75830. declare module BABYLON.GLTF1 {
  75831. /** @hidden */
  75832. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75833. private _bin;
  75834. constructor();
  75835. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75836. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75837. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75838. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75839. }
  75840. }
  75841. declare module BABYLON.GLTF1 {
  75842. /** @hidden */
  75843. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75844. constructor();
  75845. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75846. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75847. private _loadTexture;
  75848. }
  75849. }
  75850. declare module BABYLON.GLTF2.Loader {
  75851. /**
  75852. * Loader interface with an index field.
  75853. */
  75854. export interface IArrayItem {
  75855. /**
  75856. * The index of this item in the array.
  75857. */
  75858. index: number;
  75859. }
  75860. /**
  75861. * Loader interface with additional members.
  75862. */
  75863. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75864. /** @hidden */
  75865. _data?: Promise<ArrayBufferView>;
  75866. /** @hidden */
  75867. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75868. }
  75869. /**
  75870. * Loader interface with additional members.
  75871. */
  75872. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75873. }
  75874. /** @hidden */
  75875. export interface _IAnimationSamplerData {
  75876. input: Float32Array;
  75877. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75878. output: Float32Array;
  75879. }
  75880. /**
  75881. * Loader interface with additional members.
  75882. */
  75883. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75884. /** @hidden */
  75885. _data?: Promise<_IAnimationSamplerData>;
  75886. }
  75887. /**
  75888. * Loader interface with additional members.
  75889. */
  75890. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75891. channels: IAnimationChannel[];
  75892. samplers: IAnimationSampler[];
  75893. /** @hidden */
  75894. _babylonAnimationGroup?: AnimationGroup;
  75895. }
  75896. /**
  75897. * Loader interface with additional members.
  75898. */
  75899. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75900. /** @hidden */
  75901. _data?: Promise<ArrayBufferView>;
  75902. }
  75903. /**
  75904. * Loader interface with additional members.
  75905. */
  75906. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75907. /** @hidden */
  75908. _data?: Promise<ArrayBufferView>;
  75909. /** @hidden */
  75910. _babylonBuffer?: Promise<Buffer>;
  75911. }
  75912. /**
  75913. * Loader interface with additional members.
  75914. */
  75915. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75916. }
  75917. /**
  75918. * Loader interface with additional members.
  75919. */
  75920. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75921. /** @hidden */
  75922. _data?: Promise<ArrayBufferView>;
  75923. }
  75924. /**
  75925. * Loader interface with additional members.
  75926. */
  75927. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75928. }
  75929. /**
  75930. * Loader interface with additional members.
  75931. */
  75932. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75933. }
  75934. /**
  75935. * Loader interface with additional members.
  75936. */
  75937. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75938. baseColorTexture?: ITextureInfo;
  75939. metallicRoughnessTexture?: ITextureInfo;
  75940. }
  75941. /**
  75942. * Loader interface with additional members.
  75943. */
  75944. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75945. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75946. normalTexture?: IMaterialNormalTextureInfo;
  75947. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75948. emissiveTexture?: ITextureInfo;
  75949. /** @hidden */
  75950. _data?: {
  75951. [babylonDrawMode: number]: {
  75952. babylonMaterial: Material;
  75953. babylonMeshes: AbstractMesh[];
  75954. promise: Promise<void>;
  75955. };
  75956. };
  75957. }
  75958. /**
  75959. * Loader interface with additional members.
  75960. */
  75961. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75962. primitives: IMeshPrimitive[];
  75963. }
  75964. /**
  75965. * Loader interface with additional members.
  75966. */
  75967. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75968. /** @hidden */
  75969. _instanceData?: {
  75970. babylonSourceMesh: Mesh;
  75971. promise: Promise<any>;
  75972. };
  75973. }
  75974. /**
  75975. * Loader interface with additional members.
  75976. */
  75977. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75978. /**
  75979. * The parent glTF node.
  75980. */
  75981. parent?: INode;
  75982. /** @hidden */
  75983. _babylonTransformNode?: TransformNode;
  75984. /** @hidden */
  75985. _primitiveBabylonMeshes?: AbstractMesh[];
  75986. /** @hidden */
  75987. _babylonBones?: Bone[];
  75988. /** @hidden */
  75989. _numMorphTargets?: number;
  75990. }
  75991. /** @hidden */
  75992. export interface _ISamplerData {
  75993. noMipMaps: boolean;
  75994. samplingMode: number;
  75995. wrapU: number;
  75996. wrapV: number;
  75997. }
  75998. /**
  75999. * Loader interface with additional members.
  76000. */
  76001. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76002. /** @hidden */
  76003. _data?: _ISamplerData;
  76004. }
  76005. /**
  76006. * Loader interface with additional members.
  76007. */
  76008. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76009. }
  76010. /**
  76011. * Loader interface with additional members.
  76012. */
  76013. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76014. /** @hidden */
  76015. _data?: {
  76016. babylonSkeleton: Skeleton;
  76017. promise: Promise<void>;
  76018. };
  76019. }
  76020. /**
  76021. * Loader interface with additional members.
  76022. */
  76023. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76024. }
  76025. /**
  76026. * Loader interface with additional members.
  76027. */
  76028. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76029. }
  76030. /**
  76031. * Loader interface with additional members.
  76032. */
  76033. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76034. accessors?: IAccessor[];
  76035. animations?: IAnimation[];
  76036. buffers?: IBuffer[];
  76037. bufferViews?: IBufferView[];
  76038. cameras?: ICamera[];
  76039. images?: IImage[];
  76040. materials?: IMaterial[];
  76041. meshes?: IMesh[];
  76042. nodes?: INode[];
  76043. samplers?: ISampler[];
  76044. scenes?: IScene[];
  76045. skins?: ISkin[];
  76046. textures?: ITexture[];
  76047. }
  76048. }
  76049. declare module BABYLON.GLTF2 {
  76050. /**
  76051. * Interface for a glTF loader extension.
  76052. */
  76053. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76054. /**
  76055. * Called after the loader state changes to LOADING.
  76056. */
  76057. onLoading?(): void;
  76058. /**
  76059. * Called after the loader state changes to READY.
  76060. */
  76061. onReady?(): void;
  76062. /**
  76063. * Define this method to modify the default behavior when loading scenes.
  76064. * @param context The context when loading the asset
  76065. * @param scene The glTF scene property
  76066. * @returns A promise that resolves when the load is complete or null if not handled
  76067. */
  76068. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76069. /**
  76070. * Define this method to modify the default behavior when loading nodes.
  76071. * @param context The context when loading the asset
  76072. * @param node The glTF node property
  76073. * @param assign A function called synchronously after parsing the glTF properties
  76074. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76075. */
  76076. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76077. /**
  76078. * Define this method to modify the default behavior when loading cameras.
  76079. * @param context The context when loading the asset
  76080. * @param camera The glTF camera property
  76081. * @param assign A function called synchronously after parsing the glTF properties
  76082. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76083. */
  76084. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76085. /**
  76086. * @hidden
  76087. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76088. * @param context The context when loading the asset
  76089. * @param primitive The glTF mesh primitive property
  76090. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76091. */
  76092. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76093. /**
  76094. * @hidden
  76095. * Define this method to modify the default behavior when loading data for mesh primitives.
  76096. * @param context The context when loading the asset
  76097. * @param name The mesh name when loading the asset
  76098. * @param node The glTF node when loading the asset
  76099. * @param mesh The glTF mesh when loading the asset
  76100. * @param primitive The glTF mesh primitive property
  76101. * @param assign A function called synchronously after parsing the glTF properties
  76102. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76103. */
  76104. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76105. /**
  76106. * @hidden
  76107. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76108. * @param context The context when loading the asset
  76109. * @param material The glTF material property
  76110. * @param assign A function called synchronously after parsing the glTF properties
  76111. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76112. */
  76113. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76114. /**
  76115. * Define this method to modify the default behavior when creating materials.
  76116. * @param context The context when loading the asset
  76117. * @param material The glTF material property
  76118. * @param babylonDrawMode The draw mode for the Babylon material
  76119. * @returns The Babylon material or null if not handled
  76120. */
  76121. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76122. /**
  76123. * Define this method to modify the default behavior when loading material properties.
  76124. * @param context The context when loading the asset
  76125. * @param material The glTF material property
  76126. * @param babylonMaterial The Babylon material
  76127. * @returns A promise that resolves when the load is complete or null if not handled
  76128. */
  76129. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76130. /**
  76131. * Define this method to modify the default behavior when loading texture infos.
  76132. * @param context The context when loading the asset
  76133. * @param textureInfo The glTF texture info property
  76134. * @param assign A function called synchronously after parsing the glTF properties
  76135. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76136. */
  76137. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76138. /**
  76139. * @hidden
  76140. * Define this method to modify the default behavior when loading textures.
  76141. * @param context The context when loading the asset
  76142. * @param texture The glTF texture property
  76143. * @param assign A function called synchronously after parsing the glTF properties
  76144. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76145. */
  76146. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76147. /**
  76148. * Define this method to modify the default behavior when loading animations.
  76149. * @param context The context when loading the asset
  76150. * @param animation The glTF animation property
  76151. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76152. */
  76153. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76154. /**
  76155. * @hidden
  76156. * Define this method to modify the default behavior when loading skins.
  76157. * @param context The context when loading the asset
  76158. * @param node The glTF node property
  76159. * @param skin The glTF skin property
  76160. * @returns A promise that resolves when the load is complete or null if not handled
  76161. */
  76162. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76163. /**
  76164. * @hidden
  76165. * Define this method to modify the default behavior when loading uris.
  76166. * @param context The context when loading the asset
  76167. * @param property The glTF property associated with the uri
  76168. * @param uri The uri to load
  76169. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76170. */
  76171. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76172. /**
  76173. * Define this method to modify the default behavior when loading buffer views.
  76174. * @param context The context when loading the asset
  76175. * @param bufferView The glTF buffer view property
  76176. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76177. */
  76178. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76179. /**
  76180. * Define this method to modify the default behavior when loading buffers.
  76181. * @param context The context when loading the asset
  76182. * @param buffer The glTF buffer property
  76183. * @param byteOffset The byte offset to load
  76184. * @param byteLength The byte length to load
  76185. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76186. */
  76187. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76188. }
  76189. }
  76190. declare module BABYLON.GLTF2 {
  76191. /**
  76192. * Helper class for working with arrays when loading the glTF asset
  76193. */
  76194. export class ArrayItem {
  76195. /**
  76196. * Gets an item from the given array.
  76197. * @param context The context when loading the asset
  76198. * @param array The array to get the item from
  76199. * @param index The index to the array
  76200. * @returns The array item
  76201. */
  76202. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76203. /**
  76204. * Assign an `index` field to each item of the given array.
  76205. * @param array The array of items
  76206. */
  76207. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76208. }
  76209. /**
  76210. * The glTF 2.0 loader
  76211. */
  76212. export class GLTFLoader implements IGLTFLoader {
  76213. /** @hidden */
  76214. _completePromises: Promise<any>[];
  76215. /** @hidden */
  76216. _forAssetContainer: boolean;
  76217. /** Storage */
  76218. _babylonLights: Light[];
  76219. private _disposed;
  76220. private _parent;
  76221. private _state;
  76222. private _extensions;
  76223. private _rootUrl;
  76224. private _fileName;
  76225. private _uniqueRootUrl;
  76226. private _gltf;
  76227. private _bin;
  76228. private _babylonScene;
  76229. private _rootBabylonMesh;
  76230. private _defaultBabylonMaterialData;
  76231. private _progressCallback?;
  76232. private _requests;
  76233. private static _RegisteredExtensions;
  76234. /**
  76235. * The default glTF sampler.
  76236. */
  76237. static readonly DefaultSampler: ISampler;
  76238. /**
  76239. * Registers a loader extension.
  76240. * @param name The name of the loader extension.
  76241. * @param factory The factory function that creates the loader extension.
  76242. */
  76243. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76244. /**
  76245. * Unregisters a loader extension.
  76246. * @param name The name of the loader extension.
  76247. * @returns A boolean indicating whether the extension has been unregistered
  76248. */
  76249. static UnregisterExtension(name: string): boolean;
  76250. /**
  76251. * The loader state.
  76252. */
  76253. get state(): Nullable<GLTFLoaderState>;
  76254. /**
  76255. * The object that represents the glTF JSON.
  76256. */
  76257. get gltf(): IGLTF;
  76258. /**
  76259. * The BIN chunk of a binary glTF.
  76260. */
  76261. get bin(): Nullable<IDataBuffer>;
  76262. /**
  76263. * The parent file loader.
  76264. */
  76265. get parent(): GLTFFileLoader;
  76266. /**
  76267. * The Babylon scene when loading the asset.
  76268. */
  76269. get babylonScene(): Scene;
  76270. /**
  76271. * The root Babylon mesh when loading the asset.
  76272. */
  76273. get rootBabylonMesh(): Mesh;
  76274. /** @hidden */
  76275. constructor(parent: GLTFFileLoader);
  76276. /** @hidden */
  76277. dispose(): void;
  76278. /** @hidden */
  76279. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76280. /** @hidden */
  76281. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76282. private _loadAsync;
  76283. private _loadData;
  76284. private _setupData;
  76285. private _loadExtensions;
  76286. private _checkExtensions;
  76287. private _setState;
  76288. private _createRootNode;
  76289. /**
  76290. * Loads a glTF scene.
  76291. * @param context The context when loading the asset
  76292. * @param scene The glTF scene property
  76293. * @returns A promise that resolves when the load is complete
  76294. */
  76295. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76296. private _forEachPrimitive;
  76297. private _getMeshes;
  76298. private _getTransformNodes;
  76299. private _getSkeletons;
  76300. private _getAnimationGroups;
  76301. private _startAnimations;
  76302. /**
  76303. * Loads a glTF node.
  76304. * @param context The context when loading the asset
  76305. * @param node The glTF node property
  76306. * @param assign A function called synchronously after parsing the glTF properties
  76307. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76308. */
  76309. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76310. private _loadMeshAsync;
  76311. /**
  76312. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76313. * @param context The context when loading the asset
  76314. * @param name The mesh name when loading the asset
  76315. * @param node The glTF node when loading the asset
  76316. * @param mesh The glTF mesh when loading the asset
  76317. * @param primitive The glTF mesh primitive property
  76318. * @param assign A function called synchronously after parsing the glTF properties
  76319. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76320. */
  76321. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76322. private _loadVertexDataAsync;
  76323. private _createMorphTargets;
  76324. private _loadMorphTargetsAsync;
  76325. private _loadMorphTargetVertexDataAsync;
  76326. private static _LoadTransform;
  76327. private _loadSkinAsync;
  76328. private _loadBones;
  76329. private _loadBone;
  76330. private _loadSkinInverseBindMatricesDataAsync;
  76331. private _updateBoneMatrices;
  76332. private _getNodeMatrix;
  76333. /**
  76334. * Loads a glTF camera.
  76335. * @param context The context when loading the asset
  76336. * @param camera The glTF camera property
  76337. * @param assign A function called synchronously after parsing the glTF properties
  76338. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76339. */
  76340. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76341. private _loadAnimationsAsync;
  76342. /**
  76343. * Loads a glTF animation.
  76344. * @param context The context when loading the asset
  76345. * @param animation The glTF animation property
  76346. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76347. */
  76348. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76349. /**
  76350. * @hidden Loads a glTF animation channel.
  76351. * @param context The context when loading the asset
  76352. * @param animationContext The context of the animation when loading the asset
  76353. * @param animation The glTF animation property
  76354. * @param channel The glTF animation channel property
  76355. * @param babylonAnimationGroup The babylon animation group property
  76356. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76357. * @returns A void promise when the channel load is complete
  76358. */
  76359. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76360. private _loadAnimationSamplerAsync;
  76361. private _loadBufferAsync;
  76362. /**
  76363. * Loads a glTF buffer view.
  76364. * @param context The context when loading the asset
  76365. * @param bufferView The glTF buffer view property
  76366. * @returns A promise that resolves with the loaded data when the load is complete
  76367. */
  76368. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76369. private _loadAccessorAsync;
  76370. /** @hidden */
  76371. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76372. private _loadIndicesAccessorAsync;
  76373. private _loadVertexBufferViewAsync;
  76374. private _loadVertexAccessorAsync;
  76375. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76376. /** @hidden */
  76377. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76378. private _createDefaultMaterial;
  76379. /**
  76380. * Creates a Babylon material from a glTF material.
  76381. * @param context The context when loading the asset
  76382. * @param material The glTF material property
  76383. * @param babylonDrawMode The draw mode for the Babylon material
  76384. * @returns The Babylon material
  76385. */
  76386. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76387. /**
  76388. * Loads properties from a glTF material into a Babylon material.
  76389. * @param context The context when loading the asset
  76390. * @param material The glTF material property
  76391. * @param babylonMaterial The Babylon material
  76392. * @returns A promise that resolves when the load is complete
  76393. */
  76394. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76395. /**
  76396. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76397. * @param context The context when loading the asset
  76398. * @param material The glTF material property
  76399. * @param babylonMaterial The Babylon material
  76400. * @returns A promise that resolves when the load is complete
  76401. */
  76402. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76403. /**
  76404. * Loads the alpha properties from a glTF material into a Babylon material.
  76405. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76406. * @param context The context when loading the asset
  76407. * @param material The glTF material property
  76408. * @param babylonMaterial The Babylon material
  76409. */
  76410. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76411. /**
  76412. * Loads a glTF texture info.
  76413. * @param context The context when loading the asset
  76414. * @param textureInfo The glTF texture info property
  76415. * @param assign A function called synchronously after parsing the glTF properties
  76416. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76417. */
  76418. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76419. /** @hidden */
  76420. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76421. /** @hidden */
  76422. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76423. private _loadSampler;
  76424. /**
  76425. * Loads a glTF image.
  76426. * @param context The context when loading the asset
  76427. * @param image The glTF image property
  76428. * @returns A promise that resolves with the loaded data when the load is complete
  76429. */
  76430. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76431. /**
  76432. * Loads a glTF uri.
  76433. * @param context The context when loading the asset
  76434. * @param property The glTF property associated with the uri
  76435. * @param uri The base64 or relative uri
  76436. * @returns A promise that resolves with the loaded data when the load is complete
  76437. */
  76438. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76439. private _onProgress;
  76440. /**
  76441. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76442. * @param babylonObject the Babylon object with metadata
  76443. * @param pointer the JSON pointer
  76444. */
  76445. static AddPointerMetadata(babylonObject: {
  76446. metadata: any;
  76447. }, pointer: string): void;
  76448. private static _GetTextureWrapMode;
  76449. private static _GetTextureSamplingMode;
  76450. private static _GetTypedArrayConstructor;
  76451. private static _GetTypedArray;
  76452. private static _GetNumComponents;
  76453. private static _ValidateUri;
  76454. private static _GetDrawMode;
  76455. private _compileMaterialsAsync;
  76456. private _compileShadowGeneratorsAsync;
  76457. private _forEachExtensions;
  76458. private _applyExtensions;
  76459. private _extensionsOnLoading;
  76460. private _extensionsOnReady;
  76461. private _extensionsLoadSceneAsync;
  76462. private _extensionsLoadNodeAsync;
  76463. private _extensionsLoadCameraAsync;
  76464. private _extensionsLoadVertexDataAsync;
  76465. private _extensionsLoadMeshPrimitiveAsync;
  76466. private _extensionsLoadMaterialAsync;
  76467. private _extensionsCreateMaterial;
  76468. private _extensionsLoadMaterialPropertiesAsync;
  76469. private _extensionsLoadTextureInfoAsync;
  76470. private _extensionsLoadTextureAsync;
  76471. private _extensionsLoadAnimationAsync;
  76472. private _extensionsLoadSkinAsync;
  76473. private _extensionsLoadUriAsync;
  76474. private _extensionsLoadBufferViewAsync;
  76475. private _extensionsLoadBufferAsync;
  76476. /**
  76477. * Helper method called by a loader extension to load an glTF extension.
  76478. * @param context The context when loading the asset
  76479. * @param property The glTF property to load the extension from
  76480. * @param extensionName The name of the extension to load
  76481. * @param actionAsync The action to run
  76482. * @returns The promise returned by actionAsync or null if the extension does not exist
  76483. */
  76484. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76485. /**
  76486. * Helper method called by a loader extension to load a glTF extra.
  76487. * @param context The context when loading the asset
  76488. * @param property The glTF property to load the extra from
  76489. * @param extensionName The name of the extension to load
  76490. * @param actionAsync The action to run
  76491. * @returns The promise returned by actionAsync or null if the extra does not exist
  76492. */
  76493. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76494. /**
  76495. * Checks for presence of an extension.
  76496. * @param name The name of the extension to check
  76497. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76498. */
  76499. isExtensionUsed(name: string): boolean;
  76500. /**
  76501. * Increments the indentation level and logs a message.
  76502. * @param message The message to log
  76503. */
  76504. logOpen(message: string): void;
  76505. /**
  76506. * Decrements the indentation level.
  76507. */
  76508. logClose(): void;
  76509. /**
  76510. * Logs a message
  76511. * @param message The message to log
  76512. */
  76513. log(message: string): void;
  76514. /**
  76515. * Starts a performance counter.
  76516. * @param counterName The name of the performance counter
  76517. */
  76518. startPerformanceCounter(counterName: string): void;
  76519. /**
  76520. * Ends a performance counter.
  76521. * @param counterName The name of the performance counter
  76522. */
  76523. endPerformanceCounter(counterName: string): void;
  76524. }
  76525. }
  76526. declare module BABYLON.GLTF2.Loader.Extensions {
  76527. /**
  76528. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76529. */
  76530. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76531. /**
  76532. * The name of this extension.
  76533. */
  76534. readonly name: string;
  76535. /**
  76536. * Defines whether this extension is enabled.
  76537. */
  76538. enabled: boolean;
  76539. private _loader;
  76540. private _lights?;
  76541. /** @hidden */
  76542. constructor(loader: GLTFLoader);
  76543. /** @hidden */
  76544. dispose(): void;
  76545. /** @hidden */
  76546. onLoading(): void;
  76547. /** @hidden */
  76548. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76549. private _loadLightAsync;
  76550. }
  76551. }
  76552. declare module BABYLON.GLTF2.Loader.Extensions {
  76553. /**
  76554. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76555. */
  76556. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76557. /**
  76558. * The name of this extension.
  76559. */
  76560. readonly name: string;
  76561. /**
  76562. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76563. */
  76564. dracoCompression?: DracoCompression;
  76565. /**
  76566. * Defines whether this extension is enabled.
  76567. */
  76568. enabled: boolean;
  76569. private _loader;
  76570. /** @hidden */
  76571. constructor(loader: GLTFLoader);
  76572. /** @hidden */
  76573. dispose(): void;
  76574. /** @hidden */
  76575. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76576. }
  76577. }
  76578. declare module BABYLON.GLTF2.Loader.Extensions {
  76579. /**
  76580. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76581. */
  76582. export class KHR_lights implements IGLTFLoaderExtension {
  76583. /**
  76584. * The name of this extension.
  76585. */
  76586. readonly name: string;
  76587. /**
  76588. * Defines whether this extension is enabled.
  76589. */
  76590. enabled: boolean;
  76591. private _loader;
  76592. private _lights?;
  76593. /** @hidden */
  76594. constructor(loader: GLTFLoader);
  76595. /** @hidden */
  76596. dispose(): void;
  76597. /** @hidden */
  76598. onLoading(): void;
  76599. /** @hidden */
  76600. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76601. }
  76602. }
  76603. declare module BABYLON.GLTF2.Loader.Extensions {
  76604. /**
  76605. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76606. */
  76607. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76608. /**
  76609. * The name of this extension.
  76610. */
  76611. readonly name: string;
  76612. /**
  76613. * Defines whether this extension is enabled.
  76614. */
  76615. enabled: boolean;
  76616. /**
  76617. * Defines a number that determines the order the extensions are applied.
  76618. */
  76619. order: number;
  76620. private _loader;
  76621. /** @hidden */
  76622. constructor(loader: GLTFLoader);
  76623. /** @hidden */
  76624. dispose(): void;
  76625. /** @hidden */
  76626. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76627. private _loadSpecularGlossinessPropertiesAsync;
  76628. }
  76629. }
  76630. declare module BABYLON.GLTF2.Loader.Extensions {
  76631. /**
  76632. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76633. */
  76634. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76635. /**
  76636. * The name of this extension.
  76637. */
  76638. readonly name: string;
  76639. /**
  76640. * Defines whether this extension is enabled.
  76641. */
  76642. enabled: boolean;
  76643. /**
  76644. * Defines a number that determines the order the extensions are applied.
  76645. */
  76646. order: number;
  76647. private _loader;
  76648. /** @hidden */
  76649. constructor(loader: GLTFLoader);
  76650. /** @hidden */
  76651. dispose(): void;
  76652. /** @hidden */
  76653. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76654. private _loadUnlitPropertiesAsync;
  76655. }
  76656. }
  76657. declare module BABYLON.GLTF2.Loader.Extensions {
  76658. /**
  76659. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76660. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76661. * !!! Experimental Extension Subject to Changes !!!
  76662. */
  76663. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76664. /**
  76665. * The name of this extension.
  76666. */
  76667. readonly name: string;
  76668. /**
  76669. * Defines whether this extension is enabled.
  76670. */
  76671. enabled: boolean;
  76672. /**
  76673. * Defines a number that determines the order the extensions are applied.
  76674. */
  76675. order: number;
  76676. private _loader;
  76677. /** @hidden */
  76678. constructor(loader: GLTFLoader);
  76679. /** @hidden */
  76680. dispose(): void;
  76681. /** @hidden */
  76682. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76683. private _loadClearCoatPropertiesAsync;
  76684. }
  76685. }
  76686. declare module BABYLON.GLTF2.Loader.Extensions {
  76687. /**
  76688. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76689. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76690. * !!! Experimental Extension Subject to Changes !!!
  76691. */
  76692. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76693. /**
  76694. * The name of this extension.
  76695. */
  76696. readonly name: string;
  76697. /**
  76698. * Defines whether this extension is enabled.
  76699. */
  76700. enabled: boolean;
  76701. /**
  76702. * Defines a number that determines the order the extensions are applied.
  76703. */
  76704. order: number;
  76705. private _loader;
  76706. /** @hidden */
  76707. constructor(loader: GLTFLoader);
  76708. /** @hidden */
  76709. dispose(): void;
  76710. /** @hidden */
  76711. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76712. private _loadSheenPropertiesAsync;
  76713. }
  76714. }
  76715. declare module BABYLON.GLTF2.Loader.Extensions {
  76716. /**
  76717. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76718. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76719. * !!! Experimental Extension Subject to Changes !!!
  76720. */
  76721. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76722. /**
  76723. * The name of this extension.
  76724. */
  76725. readonly name: string;
  76726. /**
  76727. * Defines whether this extension is enabled.
  76728. */
  76729. enabled: boolean;
  76730. /**
  76731. * Defines a number that determines the order the extensions are applied.
  76732. */
  76733. order: number;
  76734. private _loader;
  76735. /** @hidden */
  76736. constructor(loader: GLTFLoader);
  76737. /** @hidden */
  76738. dispose(): void;
  76739. /** @hidden */
  76740. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76741. private _loadSpecularPropertiesAsync;
  76742. }
  76743. }
  76744. declare module BABYLON.GLTF2.Loader.Extensions {
  76745. /**
  76746. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76747. * [Playground Sample](//TODO)
  76748. * !!! Experimental Extension Subject to Changes !!!
  76749. */
  76750. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76751. /**
  76752. * The name of this extension.
  76753. */
  76754. readonly name: string;
  76755. /**
  76756. * Defines whether this extension is enabled.
  76757. */
  76758. enabled: boolean;
  76759. private _loader;
  76760. /** @hidden */
  76761. constructor(loader: GLTFLoader);
  76762. /** @hidden */
  76763. dispose(): void;
  76764. /** @hidden */
  76765. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76766. }
  76767. }
  76768. declare module BABYLON.GLTF2.Loader.Extensions {
  76769. /**
  76770. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76771. */
  76772. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76773. /**
  76774. * The name of this extension.
  76775. */
  76776. readonly name: string;
  76777. /**
  76778. * Defines whether this extension is enabled.
  76779. */
  76780. enabled: boolean;
  76781. /** @hidden */
  76782. constructor(loader: GLTFLoader);
  76783. /** @hidden */
  76784. dispose(): void;
  76785. }
  76786. }
  76787. declare module BABYLON.GLTF2.Loader.Extensions {
  76788. /**
  76789. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76790. * !!! Experimental Extension Subject to Changes !!!
  76791. */
  76792. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76793. /** The name of this extension. */
  76794. readonly name: string;
  76795. /** Defines whether this extension is enabled. */
  76796. enabled: boolean;
  76797. private _loader;
  76798. /** @hidden */
  76799. constructor(loader: GLTFLoader);
  76800. /** @hidden */
  76801. dispose(): void;
  76802. /** @hidden */
  76803. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76804. }
  76805. }
  76806. declare module BABYLON.GLTF2.Loader.Extensions {
  76807. /**
  76808. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76809. */
  76810. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76811. /**
  76812. * The name of this extension.
  76813. */
  76814. readonly name: string;
  76815. /**
  76816. * Defines whether this extension is enabled.
  76817. */
  76818. enabled: boolean;
  76819. private _loader;
  76820. /** @hidden */
  76821. constructor(loader: GLTFLoader);
  76822. /** @hidden */
  76823. dispose(): void;
  76824. /** @hidden */
  76825. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76826. }
  76827. }
  76828. declare module BABYLON.GLTF2.Loader.Extensions {
  76829. /**
  76830. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76831. */
  76832. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76833. /**
  76834. * The name of this extension.
  76835. */
  76836. readonly name: string;
  76837. /**
  76838. * Defines whether this extension is enabled.
  76839. */
  76840. enabled: boolean;
  76841. private _loader;
  76842. private _clips;
  76843. private _emitters;
  76844. /** @hidden */
  76845. constructor(loader: GLTFLoader);
  76846. /** @hidden */
  76847. dispose(): void;
  76848. /** @hidden */
  76849. onLoading(): void;
  76850. /** @hidden */
  76851. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76852. /** @hidden */
  76853. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76854. /** @hidden */
  76855. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76856. private _loadClipAsync;
  76857. private _loadEmitterAsync;
  76858. private _getEventAction;
  76859. private _loadAnimationEventAsync;
  76860. }
  76861. }
  76862. declare module BABYLON.GLTF2.Loader.Extensions {
  76863. /**
  76864. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76865. */
  76866. export class MSFT_lod implements IGLTFLoaderExtension {
  76867. /**
  76868. * The name of this extension.
  76869. */
  76870. readonly name: string;
  76871. /**
  76872. * Defines whether this extension is enabled.
  76873. */
  76874. enabled: boolean;
  76875. /**
  76876. * Defines a number that determines the order the extensions are applied.
  76877. */
  76878. order: number;
  76879. /**
  76880. * Maximum number of LODs to load, starting from the lowest LOD.
  76881. */
  76882. maxLODsToLoad: number;
  76883. /**
  76884. * Observable raised when all node LODs of one level are loaded.
  76885. * The event data is the index of the loaded LOD starting from zero.
  76886. * Dispose the loader to cancel the loading of the next level of LODs.
  76887. */
  76888. onNodeLODsLoadedObservable: Observable<number>;
  76889. /**
  76890. * Observable raised when all material LODs of one level are loaded.
  76891. * The event data is the index of the loaded LOD starting from zero.
  76892. * Dispose the loader to cancel the loading of the next level of LODs.
  76893. */
  76894. onMaterialLODsLoadedObservable: Observable<number>;
  76895. private _loader;
  76896. private _nodeIndexLOD;
  76897. private _nodeSignalLODs;
  76898. private _nodePromiseLODs;
  76899. private _materialIndexLOD;
  76900. private _materialSignalLODs;
  76901. private _materialPromiseLODs;
  76902. private _indexLOD;
  76903. private _bufferLODs;
  76904. /** @hidden */
  76905. constructor(loader: GLTFLoader);
  76906. /** @hidden */
  76907. dispose(): void;
  76908. /** @hidden */
  76909. onReady(): void;
  76910. /** @hidden */
  76911. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76912. /** @hidden */
  76913. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76914. /** @hidden */
  76915. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76916. /** @hidden */
  76917. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76918. /** @hidden */
  76919. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76920. private _loadBufferLOD;
  76921. /**
  76922. * Gets an array of LOD properties from lowest to highest.
  76923. */
  76924. private _getLODs;
  76925. private _disposeTransformNode;
  76926. private _disposeMaterials;
  76927. }
  76928. }
  76929. declare module BABYLON.GLTF2.Loader.Extensions {
  76930. /** @hidden */
  76931. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76932. readonly name: string;
  76933. enabled: boolean;
  76934. private _loader;
  76935. constructor(loader: GLTFLoader);
  76936. dispose(): void;
  76937. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76938. }
  76939. }
  76940. declare module BABYLON.GLTF2.Loader.Extensions {
  76941. /** @hidden */
  76942. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76943. readonly name: string;
  76944. enabled: boolean;
  76945. private _loader;
  76946. constructor(loader: GLTFLoader);
  76947. dispose(): void;
  76948. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76949. }
  76950. }
  76951. declare module BABYLON.GLTF2.Loader.Extensions {
  76952. /**
  76953. * Store glTF extras (if present) in BJS objects' metadata
  76954. */
  76955. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76956. /**
  76957. * The name of this extension.
  76958. */
  76959. readonly name: string;
  76960. /**
  76961. * Defines whether this extension is enabled.
  76962. */
  76963. enabled: boolean;
  76964. private _loader;
  76965. private _assignExtras;
  76966. /** @hidden */
  76967. constructor(loader: GLTFLoader);
  76968. /** @hidden */
  76969. dispose(): void;
  76970. /** @hidden */
  76971. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76972. /** @hidden */
  76973. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76974. /** @hidden */
  76975. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76976. }
  76977. }
  76978. declare module BABYLON {
  76979. /**
  76980. * Class reading and parsing the MTL file bundled with the obj file.
  76981. */
  76982. export class MTLFileLoader {
  76983. /**
  76984. * Invert Y-Axis of referenced textures on load
  76985. */
  76986. static INVERT_TEXTURE_Y: boolean;
  76987. /**
  76988. * All material loaded from the mtl will be set here
  76989. */
  76990. materials: StandardMaterial[];
  76991. /**
  76992. * This function will read the mtl file and create each material described inside
  76993. * This function could be improve by adding :
  76994. * -some component missing (Ni, Tf...)
  76995. * -including the specific options available
  76996. *
  76997. * @param scene defines the scene the material will be created in
  76998. * @param data defines the mtl data to parse
  76999. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77000. * @param forAssetContainer defines if the material should be registered in the scene
  77001. */
  77002. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77003. /**
  77004. * Gets the texture for the material.
  77005. *
  77006. * If the material is imported from input file,
  77007. * We sanitize the url to ensure it takes the textre from aside the material.
  77008. *
  77009. * @param rootUrl The root url to load from
  77010. * @param value The value stored in the mtl
  77011. * @return The Texture
  77012. */
  77013. private static _getTexture;
  77014. }
  77015. }
  77016. declare module BABYLON {
  77017. /**
  77018. * Options for loading OBJ/MTL files
  77019. */
  77020. type MeshLoadOptions = {
  77021. /**
  77022. * Defines if UVs are optimized by default during load.
  77023. */
  77024. OptimizeWithUV: boolean;
  77025. /**
  77026. * Defines custom scaling of UV coordinates of loaded meshes.
  77027. */
  77028. UVScaling: Vector2;
  77029. /**
  77030. * Invert model on y-axis (does a model scaling inversion)
  77031. */
  77032. InvertY: boolean;
  77033. /**
  77034. * Invert Y-Axis of referenced textures on load
  77035. */
  77036. InvertTextureY: boolean;
  77037. /**
  77038. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77039. */
  77040. ImportVertexColors: boolean;
  77041. /**
  77042. * Compute the normals for the model, even if normals are present in the file.
  77043. */
  77044. ComputeNormals: boolean;
  77045. /**
  77046. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77047. */
  77048. SkipMaterials: boolean;
  77049. /**
  77050. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77051. */
  77052. MaterialLoadingFailsSilently: boolean;
  77053. };
  77054. /**
  77055. * OBJ file type loader.
  77056. * This is a babylon scene loader plugin.
  77057. */
  77058. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77059. /**
  77060. * Defines if UVs are optimized by default during load.
  77061. */
  77062. static OPTIMIZE_WITH_UV: boolean;
  77063. /**
  77064. * Invert model on y-axis (does a model scaling inversion)
  77065. */
  77066. static INVERT_Y: boolean;
  77067. /**
  77068. * Invert Y-Axis of referenced textures on load
  77069. */
  77070. static get INVERT_TEXTURE_Y(): boolean;
  77071. static set INVERT_TEXTURE_Y(value: boolean);
  77072. /**
  77073. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77074. */
  77075. static IMPORT_VERTEX_COLORS: boolean;
  77076. /**
  77077. * Compute the normals for the model, even if normals are present in the file.
  77078. */
  77079. static COMPUTE_NORMALS: boolean;
  77080. /**
  77081. * Defines custom scaling of UV coordinates of loaded meshes.
  77082. */
  77083. static UV_SCALING: Vector2;
  77084. /**
  77085. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77086. */
  77087. static SKIP_MATERIALS: boolean;
  77088. /**
  77089. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77090. *
  77091. * Defaults to true for backwards compatibility.
  77092. */
  77093. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77094. /**
  77095. * Defines the name of the plugin.
  77096. */
  77097. name: string;
  77098. /**
  77099. * Defines the extension the plugin is able to load.
  77100. */
  77101. extensions: string;
  77102. /** @hidden */
  77103. obj: RegExp;
  77104. /** @hidden */
  77105. group: RegExp;
  77106. /** @hidden */
  77107. mtllib: RegExp;
  77108. /** @hidden */
  77109. usemtl: RegExp;
  77110. /** @hidden */
  77111. smooth: RegExp;
  77112. /** @hidden */
  77113. vertexPattern: RegExp;
  77114. /** @hidden */
  77115. normalPattern: RegExp;
  77116. /** @hidden */
  77117. uvPattern: RegExp;
  77118. /** @hidden */
  77119. facePattern1: RegExp;
  77120. /** @hidden */
  77121. facePattern2: RegExp;
  77122. /** @hidden */
  77123. facePattern3: RegExp;
  77124. /** @hidden */
  77125. facePattern4: RegExp;
  77126. /** @hidden */
  77127. facePattern5: RegExp;
  77128. private _forAssetContainer;
  77129. private _meshLoadOptions;
  77130. /**
  77131. * Creates loader for .OBJ files
  77132. *
  77133. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77134. */
  77135. constructor(meshLoadOptions?: MeshLoadOptions);
  77136. private static get currentMeshLoadOptions();
  77137. /**
  77138. * Calls synchronously the MTL file attached to this obj.
  77139. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77140. * Without this function materials are not displayed in the first frame (but displayed after).
  77141. * In consequence it is impossible to get material information in your HTML file
  77142. *
  77143. * @param url The URL of the MTL file
  77144. * @param rootUrl
  77145. * @param onSuccess Callback function to be called when the MTL file is loaded
  77146. * @private
  77147. */
  77148. private _loadMTL;
  77149. /**
  77150. * Instantiates a OBJ file loader plugin.
  77151. * @returns the created plugin
  77152. */
  77153. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77154. /**
  77155. * If the data string can be loaded directly.
  77156. *
  77157. * @param data string containing the file data
  77158. * @returns if the data can be loaded directly
  77159. */
  77160. canDirectLoad(data: string): boolean;
  77161. /**
  77162. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77163. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77164. * @param scene the scene the meshes should be added to
  77165. * @param data the OBJ data to load
  77166. * @param rootUrl root url to load from
  77167. * @param onProgress event that fires when loading progress has occured
  77168. * @param fileName Defines the name of the file to load
  77169. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77170. */
  77171. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77172. meshes: AbstractMesh[];
  77173. particleSystems: IParticleSystem[];
  77174. skeletons: Skeleton[];
  77175. animationGroups: AnimationGroup[];
  77176. }>;
  77177. /**
  77178. * Imports all objects from the loaded OBJ data and adds them to the scene
  77179. * @param scene the scene the objects should be added to
  77180. * @param data the OBJ data to load
  77181. * @param rootUrl root url to load from
  77182. * @param onProgress event that fires when loading progress has occured
  77183. * @param fileName Defines the name of the file to load
  77184. * @returns a promise which completes when objects have been loaded to the scene
  77185. */
  77186. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77187. /**
  77188. * Load into an asset container.
  77189. * @param scene The scene to load into
  77190. * @param data The data to import
  77191. * @param rootUrl The root url for scene and resources
  77192. * @param onProgress The callback when the load progresses
  77193. * @param fileName Defines the name of the file to load
  77194. * @returns The loaded asset container
  77195. */
  77196. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77197. /**
  77198. * Read the OBJ file and create an Array of meshes.
  77199. * Each mesh contains all information given by the OBJ and the MTL file.
  77200. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77201. *
  77202. * @param meshesNames
  77203. * @param scene Scene The scene where are displayed the data
  77204. * @param data String The content of the obj file
  77205. * @param rootUrl String The path to the folder
  77206. * @returns Array<AbstractMesh>
  77207. * @private
  77208. */
  77209. private _parseSolid;
  77210. }
  77211. }
  77212. declare module BABYLON {
  77213. /**
  77214. * STL file type loader.
  77215. * This is a babylon scene loader plugin.
  77216. */
  77217. export class STLFileLoader implements ISceneLoaderPlugin {
  77218. /** @hidden */
  77219. solidPattern: RegExp;
  77220. /** @hidden */
  77221. facetsPattern: RegExp;
  77222. /** @hidden */
  77223. normalPattern: RegExp;
  77224. /** @hidden */
  77225. vertexPattern: RegExp;
  77226. /**
  77227. * Defines the name of the plugin.
  77228. */
  77229. name: string;
  77230. /**
  77231. * Defines the extensions the stl loader is able to load.
  77232. * force data to come in as an ArrayBuffer
  77233. * we'll convert to string if it looks like it's an ASCII .stl
  77234. */
  77235. extensions: ISceneLoaderPluginExtensions;
  77236. /**
  77237. * Import meshes into a scene.
  77238. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77239. * @param scene The scene to import into
  77240. * @param data The data to import
  77241. * @param rootUrl The root url for scene and resources
  77242. * @param meshes The meshes array to import into
  77243. * @param particleSystems The particle systems array to import into
  77244. * @param skeletons The skeletons array to import into
  77245. * @param onError The callback when import fails
  77246. * @returns True if successful or false otherwise
  77247. */
  77248. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77249. /**
  77250. * Load into a scene.
  77251. * @param scene The scene to load into
  77252. * @param data The data to import
  77253. * @param rootUrl The root url for scene and resources
  77254. * @param onError The callback when import fails
  77255. * @returns true if successful or false otherwise
  77256. */
  77257. load(scene: Scene, data: any, rootUrl: string): boolean;
  77258. /**
  77259. * Load into an asset container.
  77260. * @param scene The scene to load into
  77261. * @param data The data to import
  77262. * @param rootUrl The root url for scene and resources
  77263. * @param onError The callback when import fails
  77264. * @returns The loaded asset container
  77265. */
  77266. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77267. private _isBinary;
  77268. private _parseBinary;
  77269. private _parseASCII;
  77270. }
  77271. }
  77272. declare module BABYLON {
  77273. /**
  77274. * Class for generating OBJ data from a Babylon scene.
  77275. */
  77276. export class OBJExport {
  77277. /**
  77278. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77279. * @param mesh defines the list of meshes to serialize
  77280. * @param materials defines if materials should be exported
  77281. * @param matlibname defines the name of the associated mtl file
  77282. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77283. * @returns the OBJ content
  77284. */
  77285. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77286. /**
  77287. * Exports the material(s) of a mesh in .MTL file format (text)
  77288. * @param mesh defines the mesh to extract the material from
  77289. * @returns the mtl content
  77290. */
  77291. static MTL(mesh: Mesh): string;
  77292. }
  77293. }
  77294. declare module BABYLON {
  77295. /** @hidden */
  77296. export var __IGLTFExporterExtension: number;
  77297. /**
  77298. * Interface for extending the exporter
  77299. * @hidden
  77300. */
  77301. export interface IGLTFExporterExtension {
  77302. /**
  77303. * The name of this extension
  77304. */
  77305. readonly name: string;
  77306. /**
  77307. * Defines whether this extension is enabled
  77308. */
  77309. enabled: boolean;
  77310. /**
  77311. * Defines whether this extension is required
  77312. */
  77313. required: boolean;
  77314. }
  77315. }
  77316. declare module BABYLON.GLTF2.Exporter {
  77317. /** @hidden */
  77318. export var __IGLTFExporterExtensionV2: number;
  77319. /**
  77320. * Interface for a glTF exporter extension
  77321. * @hidden
  77322. */
  77323. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77324. /**
  77325. * Define this method to modify the default behavior before exporting a texture
  77326. * @param context The context when loading the asset
  77327. * @param babylonTexture The Babylon.js texture
  77328. * @param mimeType The mime-type of the generated image
  77329. * @returns A promise that resolves with the exported texture
  77330. */
  77331. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77332. /**
  77333. * Define this method to get notified when a texture info is created
  77334. * @param context The context when loading the asset
  77335. * @param textureInfo The glTF texture info
  77336. * @param babylonTexture The Babylon.js texture
  77337. */
  77338. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77339. /**
  77340. * Define this method to modify the default behavior when exporting texture info
  77341. * @param context The context when loading the asset
  77342. * @param meshPrimitive glTF mesh primitive
  77343. * @param babylonSubMesh Babylon submesh
  77344. * @param binaryWriter glTF serializer binary writer instance
  77345. * @returns nullable IMeshPrimitive promise
  77346. */
  77347. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77348. /**
  77349. * Define this method to modify the default behavior when exporting a node
  77350. * @param context The context when exporting the node
  77351. * @param node glTF node
  77352. * @param babylonNode BabylonJS node
  77353. * @returns nullable INode promise
  77354. */
  77355. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77356. [key: number]: number;
  77357. }): Promise<Nullable<INode>>;
  77358. /**
  77359. * Define this method to modify the default behavior when exporting a material
  77360. * @param material glTF material
  77361. * @param babylonMaterial BabylonJS material
  77362. * @returns nullable IMaterial promise
  77363. */
  77364. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77365. /**
  77366. * Define this method to return additional textures to export from a material
  77367. * @param material glTF material
  77368. * @param babylonMaterial BabylonJS material
  77369. * @returns List of textures
  77370. */
  77371. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77372. /** Gets a boolean indicating that this extension was used */
  77373. wasUsed: boolean;
  77374. /** Gets a boolean indicating that this extension is required for the file to work */
  77375. required: boolean;
  77376. /**
  77377. * Called after the exporter state changes to EXPORTING
  77378. */
  77379. onExporting?(): void;
  77380. }
  77381. }
  77382. declare module BABYLON.GLTF2.Exporter {
  77383. /**
  77384. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77385. * @hidden
  77386. */
  77387. export class _GLTFMaterialExporter {
  77388. /**
  77389. * Represents the dielectric specular values for R, G and B
  77390. */
  77391. private static readonly _DielectricSpecular;
  77392. /**
  77393. * Allows the maximum specular power to be defined for material calculations
  77394. */
  77395. private static readonly _MaxSpecularPower;
  77396. /**
  77397. * Mapping to store textures
  77398. */
  77399. private _textureMap;
  77400. /**
  77401. * Numeric tolerance value
  77402. */
  77403. private static readonly _Epsilon;
  77404. /**
  77405. * Reference to the glTF Exporter
  77406. */
  77407. private _exporter;
  77408. constructor(exporter: _Exporter);
  77409. /**
  77410. * Specifies if two colors are approximately equal in value
  77411. * @param color1 first color to compare to
  77412. * @param color2 second color to compare to
  77413. * @param epsilon threshold value
  77414. */
  77415. private static FuzzyEquals;
  77416. /**
  77417. * Gets the materials from a Babylon scene and converts them to glTF materials
  77418. * @param scene babylonjs scene
  77419. * @param mimeType texture mime type
  77420. * @param images array of images
  77421. * @param textures array of textures
  77422. * @param materials array of materials
  77423. * @param imageData mapping of texture names to base64 textures
  77424. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77425. */
  77426. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77427. /**
  77428. * Makes a copy of the glTF material without the texture parameters
  77429. * @param originalMaterial original glTF material
  77430. * @returns glTF material without texture parameters
  77431. */
  77432. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77433. /**
  77434. * Specifies if the material has any texture parameters present
  77435. * @param material glTF Material
  77436. * @returns boolean specifying if texture parameters are present
  77437. */
  77438. _hasTexturesPresent(material: IMaterial): boolean;
  77439. /**
  77440. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77441. * @param babylonStandardMaterial
  77442. * @returns glTF Metallic Roughness Material representation
  77443. */
  77444. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77445. /**
  77446. * Computes the metallic factor
  77447. * @param diffuse diffused value
  77448. * @param specular specular value
  77449. * @param oneMinusSpecularStrength one minus the specular strength
  77450. * @returns metallic value
  77451. */
  77452. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77453. /**
  77454. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77455. * @param glTFMaterial glTF material
  77456. * @param babylonMaterial Babylon material
  77457. */
  77458. private static _SetAlphaMode;
  77459. /**
  77460. * Converts a Babylon Standard Material to a glTF Material
  77461. * @param babylonStandardMaterial BJS Standard Material
  77462. * @param mimeType mime type to use for the textures
  77463. * @param images array of glTF image interfaces
  77464. * @param textures array of glTF texture interfaces
  77465. * @param materials array of glTF material interfaces
  77466. * @param imageData map of image file name to data
  77467. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77468. */
  77469. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77470. private _finishMaterial;
  77471. /**
  77472. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77473. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77474. * @param mimeType mime type to use for the textures
  77475. * @param images array of glTF image interfaces
  77476. * @param textures array of glTF texture interfaces
  77477. * @param materials array of glTF material interfaces
  77478. * @param imageData map of image file name to data
  77479. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77480. */
  77481. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77482. /**
  77483. * Converts an image typed array buffer to a base64 image
  77484. * @param buffer typed array buffer
  77485. * @param width width of the image
  77486. * @param height height of the image
  77487. * @param mimeType mimetype of the image
  77488. * @returns base64 image string
  77489. */
  77490. private _createBase64FromCanvasAsync;
  77491. /**
  77492. * Generates a white texture based on the specified width and height
  77493. * @param width width of the texture in pixels
  77494. * @param height height of the texture in pixels
  77495. * @param scene babylonjs scene
  77496. * @returns white texture
  77497. */
  77498. private _createWhiteTexture;
  77499. /**
  77500. * 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
  77501. * @param texture1 first texture to resize
  77502. * @param texture2 second texture to resize
  77503. * @param scene babylonjs scene
  77504. * @returns resized textures or null
  77505. */
  77506. private _resizeTexturesToSameDimensions;
  77507. /**
  77508. * Converts an array of pixels to a Float32Array
  77509. * Throws an error if the pixel format is not supported
  77510. * @param pixels - array buffer containing pixel values
  77511. * @returns Float32 of pixels
  77512. */
  77513. private _convertPixelArrayToFloat32;
  77514. /**
  77515. * Convert Specular Glossiness Textures to Metallic Roughness
  77516. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77517. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77518. * @param diffuseTexture texture used to store diffuse information
  77519. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77520. * @param factors specular glossiness material factors
  77521. * @param mimeType the mime type to use for the texture
  77522. * @returns pbr metallic roughness interface or null
  77523. */
  77524. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77525. /**
  77526. * Converts specular glossiness material properties to metallic roughness
  77527. * @param specularGlossiness interface with specular glossiness material properties
  77528. * @returns interface with metallic roughness material properties
  77529. */
  77530. private _convertSpecularGlossinessToMetallicRoughness;
  77531. /**
  77532. * Calculates the surface reflectance, independent of lighting conditions
  77533. * @param color Color source to calculate brightness from
  77534. * @returns number representing the perceived brightness, or zero if color is undefined
  77535. */
  77536. private _getPerceivedBrightness;
  77537. /**
  77538. * Returns the maximum color component value
  77539. * @param color
  77540. * @returns maximum color component value, or zero if color is null or undefined
  77541. */
  77542. private _getMaxComponent;
  77543. /**
  77544. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77545. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77546. * @param mimeType mime type to use for the textures
  77547. * @param images array of glTF image interfaces
  77548. * @param textures array of glTF texture interfaces
  77549. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77550. * @param imageData map of image file name to data
  77551. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77552. * @returns glTF PBR Metallic Roughness factors
  77553. */
  77554. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77555. private _getGLTFTextureSampler;
  77556. private _getGLTFTextureWrapMode;
  77557. private _getGLTFTextureWrapModesSampler;
  77558. /**
  77559. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77560. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77561. * @param mimeType mime type to use for the textures
  77562. * @param images array of glTF image interfaces
  77563. * @param textures array of glTF texture interfaces
  77564. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77565. * @param imageData map of image file name to data
  77566. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77567. * @returns glTF PBR Metallic Roughness factors
  77568. */
  77569. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77570. /**
  77571. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77572. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77573. * @param mimeType mime type to use for the textures
  77574. * @param images array of glTF image interfaces
  77575. * @param textures array of glTF texture interfaces
  77576. * @param materials array of glTF material interfaces
  77577. * @param imageData map of image file name to data
  77578. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77579. */
  77580. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77581. private setMetallicRoughnessPbrMaterial;
  77582. private getPixelsFromTexture;
  77583. /**
  77584. * Extracts a texture from a Babylon texture into file data and glTF data
  77585. * @param babylonTexture Babylon texture to extract
  77586. * @param mimeType Mime Type of the babylonTexture
  77587. * @return glTF texture info, or null if the texture format is not supported
  77588. */
  77589. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77590. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77591. /**
  77592. * Builds a texture from base64 string
  77593. * @param base64Texture base64 texture string
  77594. * @param baseTextureName Name to use for the texture
  77595. * @param mimeType image mime type for the texture
  77596. * @param images array of images
  77597. * @param textures array of textures
  77598. * @param imageData map of image data
  77599. * @returns glTF texture info, or null if the texture format is not supported
  77600. */
  77601. private _getTextureInfoFromBase64;
  77602. }
  77603. }
  77604. declare module BABYLON {
  77605. /**
  77606. * Class for holding and downloading glTF file data
  77607. */
  77608. export class GLTFData {
  77609. /**
  77610. * Object which contains the file name as the key and its data as the value
  77611. */
  77612. glTFFiles: {
  77613. [fileName: string]: string | Blob;
  77614. };
  77615. /**
  77616. * Initializes the glTF file object
  77617. */
  77618. constructor();
  77619. /**
  77620. * Downloads the glTF data as files based on their names and data
  77621. */
  77622. downloadFiles(): void;
  77623. }
  77624. }
  77625. declare module BABYLON {
  77626. /**
  77627. * Holds a collection of exporter options and parameters
  77628. */
  77629. export interface IExportOptions {
  77630. /**
  77631. * Function which indicates whether a babylon node should be exported or not
  77632. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77633. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77634. */
  77635. shouldExportNode?(node: Node): boolean;
  77636. /**
  77637. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77638. * @param metadata source metadata to read from
  77639. * @returns the data to store to glTF node extras
  77640. */
  77641. metadataSelector?(metadata: any): any;
  77642. /**
  77643. * The sample rate to bake animation curves
  77644. */
  77645. animationSampleRate?: number;
  77646. /**
  77647. * Begin serialization without waiting for the scene to be ready
  77648. */
  77649. exportWithoutWaitingForScene?: boolean;
  77650. /**
  77651. * Indicates if coordinate system swapping root nodes should be included in export
  77652. */
  77653. includeCoordinateSystemConversionNodes?: boolean;
  77654. }
  77655. /**
  77656. * Class for generating glTF data from a Babylon scene.
  77657. */
  77658. export class GLTF2Export {
  77659. /**
  77660. * Exports the geometry of the scene to .gltf file format asynchronously
  77661. * @param scene Babylon scene with scene hierarchy information
  77662. * @param filePrefix File prefix to use when generating the glTF file
  77663. * @param options Exporter options
  77664. * @returns Returns an object with a .gltf file and associates texture names
  77665. * as keys and their data and paths as values
  77666. */
  77667. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77668. private static _PreExportAsync;
  77669. private static _PostExportAsync;
  77670. /**
  77671. * Exports the geometry of the scene to .glb file format asychronously
  77672. * @param scene Babylon scene with scene hierarchy information
  77673. * @param filePrefix File prefix to use when generating glb file
  77674. * @param options Exporter options
  77675. * @returns Returns an object with a .glb filename as key and data as value
  77676. */
  77677. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77678. }
  77679. }
  77680. declare module BABYLON.GLTF2.Exporter {
  77681. /**
  77682. * @hidden
  77683. */
  77684. export class _GLTFUtilities {
  77685. /**
  77686. * Creates a buffer view based on the supplied arguments
  77687. * @param bufferIndex index value of the specified buffer
  77688. * @param byteOffset byte offset value
  77689. * @param byteLength byte length of the bufferView
  77690. * @param byteStride byte distance between conequential elements
  77691. * @param name name of the buffer view
  77692. * @returns bufferView for glTF
  77693. */
  77694. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77695. /**
  77696. * Creates an accessor based on the supplied arguments
  77697. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77698. * @param name The name of the accessor
  77699. * @param type The type of the accessor
  77700. * @param componentType The datatype of components in the attribute
  77701. * @param count The number of attributes referenced by this accessor
  77702. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77703. * @param min Minimum value of each component in this attribute
  77704. * @param max Maximum value of each component in this attribute
  77705. * @returns accessor for glTF
  77706. */
  77707. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77708. /**
  77709. * Calculates the minimum and maximum values of an array of position floats
  77710. * @param positions Positions array of a mesh
  77711. * @param vertexStart Starting vertex offset to calculate min and max values
  77712. * @param vertexCount Number of vertices to check for min and max values
  77713. * @returns min number array and max number array
  77714. */
  77715. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77716. min: number[];
  77717. max: number[];
  77718. };
  77719. /**
  77720. * Converts a new right-handed Vector3
  77721. * @param vector vector3 array
  77722. * @returns right-handed Vector3
  77723. */
  77724. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77725. /**
  77726. * Converts a Vector3 to right-handed
  77727. * @param vector Vector3 to convert to right-handed
  77728. */
  77729. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77730. /**
  77731. * Converts a three element number array to right-handed
  77732. * @param vector number array to convert to right-handed
  77733. */
  77734. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77735. /**
  77736. * Converts a new right-handed Vector3
  77737. * @param vector vector3 array
  77738. * @returns right-handed Vector3
  77739. */
  77740. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77741. /**
  77742. * Converts a Vector3 to right-handed
  77743. * @param vector Vector3 to convert to right-handed
  77744. */
  77745. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77746. /**
  77747. * Converts a three element number array to right-handed
  77748. * @param vector number array to convert to right-handed
  77749. */
  77750. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77751. /**
  77752. * Converts a Vector4 to right-handed
  77753. * @param vector Vector4 to convert to right-handed
  77754. */
  77755. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77756. /**
  77757. * Converts a Vector4 to right-handed
  77758. * @param vector Vector4 to convert to right-handed
  77759. */
  77760. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77761. /**
  77762. * Converts a Quaternion to right-handed
  77763. * @param quaternion Source quaternion to convert to right-handed
  77764. */
  77765. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77766. /**
  77767. * Converts a Quaternion to right-handed
  77768. * @param quaternion Source quaternion to convert to right-handed
  77769. */
  77770. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77771. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77772. }
  77773. }
  77774. declare module BABYLON.GLTF2.Exporter {
  77775. /**
  77776. * Converts Babylon Scene into glTF 2.0.
  77777. * @hidden
  77778. */
  77779. export class _Exporter {
  77780. /**
  77781. * Stores the glTF to export
  77782. */
  77783. _glTF: IGLTF;
  77784. /**
  77785. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77786. */
  77787. _bufferViews: IBufferView[];
  77788. /**
  77789. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77790. */
  77791. _accessors: IAccessor[];
  77792. /**
  77793. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77794. */
  77795. _nodes: INode[];
  77796. /**
  77797. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77798. */
  77799. private _scenes;
  77800. /**
  77801. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77802. */
  77803. private _meshes;
  77804. /**
  77805. * Stores all the generated material information, which represents the appearance of each primitive
  77806. */
  77807. _materials: IMaterial[];
  77808. _materialMap: {
  77809. [materialID: number]: number;
  77810. };
  77811. /**
  77812. * Stores all the generated texture information, which is referenced by glTF materials
  77813. */
  77814. _textures: ITexture[];
  77815. /**
  77816. * Stores all the generated image information, which is referenced by glTF textures
  77817. */
  77818. _images: IImage[];
  77819. /**
  77820. * Stores all the texture samplers
  77821. */
  77822. _samplers: ISampler[];
  77823. /**
  77824. * Stores all the generated animation samplers, which is referenced by glTF animations
  77825. */
  77826. /**
  77827. * Stores the animations for glTF models
  77828. */
  77829. private _animations;
  77830. /**
  77831. * Stores the total amount of bytes stored in the glTF buffer
  77832. */
  77833. private _totalByteLength;
  77834. /**
  77835. * Stores a reference to the Babylon scene containing the source geometry and material information
  77836. */
  77837. _babylonScene: Scene;
  77838. /**
  77839. * Stores a map of the image data, where the key is the file name and the value
  77840. * is the image data
  77841. */
  77842. _imageData: {
  77843. [fileName: string]: {
  77844. data: Uint8Array;
  77845. mimeType: ImageMimeType;
  77846. };
  77847. };
  77848. /**
  77849. * Stores a map of the unique id of a node to its index in the node array
  77850. */
  77851. _nodeMap: {
  77852. [key: number]: number;
  77853. };
  77854. /**
  77855. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77856. */
  77857. _convertToRightHandedSystem: boolean;
  77858. /**
  77859. * Specifies if a Babylon node should be converted to right-handed on export
  77860. */
  77861. _convertToRightHandedSystemMap: {
  77862. [nodeId: number]: boolean;
  77863. };
  77864. _includeCoordinateSystemConversionNodes: boolean;
  77865. /**
  77866. * Baked animation sample rate
  77867. */
  77868. private _animationSampleRate;
  77869. private _options;
  77870. private _localEngine;
  77871. _glTFMaterialExporter: _GLTFMaterialExporter;
  77872. private _extensions;
  77873. private static _ExtensionNames;
  77874. private static _ExtensionFactories;
  77875. private _applyExtension;
  77876. private _applyExtensions;
  77877. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77878. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77879. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77880. [key: number]: number;
  77881. }): Promise<Nullable<INode>>;
  77882. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77883. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77884. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77885. private _forEachExtensions;
  77886. private _extensionsOnExporting;
  77887. /**
  77888. * Load glTF serializer extensions
  77889. */
  77890. private _loadExtensions;
  77891. /**
  77892. * Creates a glTF Exporter instance, which can accept optional exporter options
  77893. * @param babylonScene Babylon scene object
  77894. * @param options Options to modify the behavior of the exporter
  77895. */
  77896. constructor(babylonScene: Scene, options?: IExportOptions);
  77897. dispose(): void;
  77898. /**
  77899. * Registers a glTF exporter extension
  77900. * @param name Name of the extension to export
  77901. * @param factory The factory function that creates the exporter extension
  77902. */
  77903. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77904. /**
  77905. * Un-registers an exporter extension
  77906. * @param name The name fo the exporter extension
  77907. * @returns A boolean indicating whether the extension has been un-registered
  77908. */
  77909. static UnregisterExtension(name: string): boolean;
  77910. /**
  77911. * Lazy load a local engine
  77912. */
  77913. _getLocalEngine(): Engine;
  77914. private reorderIndicesBasedOnPrimitiveMode;
  77915. /**
  77916. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77917. * clock-wise during export to glTF
  77918. * @param submesh BabylonJS submesh
  77919. * @param primitiveMode Primitive mode of the mesh
  77920. * @param sideOrientation the winding order of the submesh
  77921. * @param vertexBufferKind The type of vertex attribute
  77922. * @param meshAttributeArray The vertex attribute data
  77923. * @param byteOffset The offset to the binary data
  77924. * @param binaryWriter The binary data for the glTF file
  77925. * @param convertToRightHandedSystem Converts the values to right-handed
  77926. */
  77927. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77928. /**
  77929. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77930. * clock-wise during export to glTF
  77931. * @param submesh BabylonJS submesh
  77932. * @param primitiveMode Primitive mode of the mesh
  77933. * @param sideOrientation the winding order of the submesh
  77934. * @param vertexBufferKind The type of vertex attribute
  77935. * @param meshAttributeArray The vertex attribute data
  77936. * @param byteOffset The offset to the binary data
  77937. * @param binaryWriter The binary data for the glTF file
  77938. * @param convertToRightHandedSystem Converts the values to right-handed
  77939. */
  77940. private reorderTriangleFillMode;
  77941. /**
  77942. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77943. * clock-wise during export to glTF
  77944. * @param submesh BabylonJS submesh
  77945. * @param primitiveMode Primitive mode of the mesh
  77946. * @param sideOrientation the winding order of the submesh
  77947. * @param vertexBufferKind The type of vertex attribute
  77948. * @param meshAttributeArray The vertex attribute data
  77949. * @param byteOffset The offset to the binary data
  77950. * @param binaryWriter The binary data for the glTF file
  77951. * @param convertToRightHandedSystem Converts the values to right-handed
  77952. */
  77953. private reorderTriangleStripDrawMode;
  77954. /**
  77955. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77956. * clock-wise during export to glTF
  77957. * @param submesh BabylonJS submesh
  77958. * @param primitiveMode Primitive mode of the mesh
  77959. * @param sideOrientation the winding order of the submesh
  77960. * @param vertexBufferKind The type of vertex attribute
  77961. * @param meshAttributeArray The vertex attribute data
  77962. * @param byteOffset The offset to the binary data
  77963. * @param binaryWriter The binary data for the glTF file
  77964. * @param convertToRightHandedSystem Converts the values to right-handed
  77965. */
  77966. private reorderTriangleFanMode;
  77967. /**
  77968. * Writes the vertex attribute data to binary
  77969. * @param vertices The vertices to write to the binary writer
  77970. * @param byteOffset The offset into the binary writer to overwrite binary data
  77971. * @param vertexAttributeKind The vertex attribute type
  77972. * @param meshAttributeArray The vertex attribute data
  77973. * @param binaryWriter The writer containing the binary data
  77974. * @param convertToRightHandedSystem Converts the values to right-handed
  77975. */
  77976. private writeVertexAttributeData;
  77977. /**
  77978. * Writes mesh attribute data to a data buffer
  77979. * Returns the bytelength of the data
  77980. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77981. * @param meshAttributeArray Array containing the attribute data
  77982. * @param binaryWriter The buffer to write the binary data to
  77983. * @param indices Used to specify the order of the vertex data
  77984. * @param convertToRightHandedSystem Converts the values to right-handed
  77985. */
  77986. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77987. /**
  77988. * Generates glTF json data
  77989. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77990. * @param glTFPrefix Text to use when prefixing a glTF file
  77991. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77992. * @returns json data as string
  77993. */
  77994. private generateJSON;
  77995. /**
  77996. * Generates data for .gltf and .bin files based on the glTF prefix string
  77997. * @param glTFPrefix Text to use when prefixing a glTF file
  77998. * @param dispose Dispose the exporter
  77999. * @returns GLTFData with glTF file data
  78000. */
  78001. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78002. /**
  78003. * Creates a binary buffer for glTF
  78004. * @returns array buffer for binary data
  78005. */
  78006. private _generateBinaryAsync;
  78007. /**
  78008. * Pads the number to a multiple of 4
  78009. * @param num number to pad
  78010. * @returns padded number
  78011. */
  78012. private _getPadding;
  78013. /**
  78014. * @hidden
  78015. */
  78016. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78017. /**
  78018. * Sets the TRS for each node
  78019. * @param node glTF Node for storing the transformation data
  78020. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78021. * @param convertToRightHandedSystem Converts the values to right-handed
  78022. */
  78023. private setNodeTransformation;
  78024. private getVertexBufferFromMesh;
  78025. /**
  78026. * Creates a bufferview based on the vertices type for the Babylon mesh
  78027. * @param kind Indicates the type of vertices data
  78028. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78029. * @param binaryWriter The buffer to write the bufferview data to
  78030. * @param convertToRightHandedSystem Converts the values to right-handed
  78031. */
  78032. private createBufferViewKind;
  78033. /**
  78034. * The primitive mode of the Babylon mesh
  78035. * @param babylonMesh The BabylonJS mesh
  78036. */
  78037. private getMeshPrimitiveMode;
  78038. /**
  78039. * Sets the primitive mode of the glTF mesh primitive
  78040. * @param meshPrimitive glTF mesh primitive
  78041. * @param primitiveMode The primitive mode
  78042. */
  78043. private setPrimitiveMode;
  78044. /**
  78045. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78046. * @param meshPrimitive glTF mesh primitive
  78047. * @param attributeKind vertex attribute
  78048. * @returns boolean specifying if uv coordinates are present
  78049. */
  78050. private setAttributeKind;
  78051. /**
  78052. * Sets data for the primitive attributes of each submesh
  78053. * @param mesh glTF Mesh object to store the primitive attribute information
  78054. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78055. * @param binaryWriter Buffer to write the attribute data to
  78056. * @param convertToRightHandedSystem Converts the values to right-handed
  78057. */
  78058. private setPrimitiveAttributesAsync;
  78059. /**
  78060. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78061. * @param node The node to check
  78062. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78063. */
  78064. private isBabylonCoordinateSystemConvertingNode;
  78065. /**
  78066. * Creates a glTF scene based on the array of meshes
  78067. * Returns the the total byte offset
  78068. * @param babylonScene Babylon scene to get the mesh data from
  78069. * @param binaryWriter Buffer to write binary data to
  78070. */
  78071. private createSceneAsync;
  78072. /**
  78073. * Creates a mapping of Node unique id to node index and handles animations
  78074. * @param babylonScene Babylon Scene
  78075. * @param nodes Babylon transform nodes
  78076. * @param binaryWriter Buffer to write binary data to
  78077. * @returns Node mapping of unique id to index
  78078. */
  78079. private createNodeMapAndAnimationsAsync;
  78080. /**
  78081. * Creates a glTF node from a Babylon mesh
  78082. * @param babylonMesh Source Babylon mesh
  78083. * @param binaryWriter Buffer for storing geometry data
  78084. * @param convertToRightHandedSystem Converts the values to right-handed
  78085. * @param nodeMap Node mapping of unique id to glTF node index
  78086. * @returns glTF node
  78087. */
  78088. private createNodeAsync;
  78089. }
  78090. /**
  78091. * @hidden
  78092. *
  78093. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78094. */
  78095. export class _BinaryWriter {
  78096. /**
  78097. * Array buffer which stores all binary data
  78098. */
  78099. private _arrayBuffer;
  78100. /**
  78101. * View of the array buffer
  78102. */
  78103. private _dataView;
  78104. /**
  78105. * byte offset of data in array buffer
  78106. */
  78107. private _byteOffset;
  78108. /**
  78109. * Initialize binary writer with an initial byte length
  78110. * @param byteLength Initial byte length of the array buffer
  78111. */
  78112. constructor(byteLength: number);
  78113. /**
  78114. * Resize the array buffer to the specified byte length
  78115. * @param byteLength
  78116. */
  78117. private resizeBuffer;
  78118. /**
  78119. * Get an array buffer with the length of the byte offset
  78120. * @returns ArrayBuffer resized to the byte offset
  78121. */
  78122. getArrayBuffer(): ArrayBuffer;
  78123. /**
  78124. * Get the byte offset of the array buffer
  78125. * @returns byte offset
  78126. */
  78127. getByteOffset(): number;
  78128. /**
  78129. * Stores an UInt8 in the array buffer
  78130. * @param entry
  78131. * @param byteOffset If defined, specifies where to set the value as an offset.
  78132. */
  78133. setUInt8(entry: number, byteOffset?: number): void;
  78134. /**
  78135. * Gets an UInt32 in the array buffer
  78136. * @param entry
  78137. * @param byteOffset If defined, specifies where to set the value as an offset.
  78138. */
  78139. getUInt32(byteOffset: number): number;
  78140. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78141. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78142. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78143. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78144. /**
  78145. * Stores a Float32 in the array buffer
  78146. * @param entry
  78147. */
  78148. setFloat32(entry: number, byteOffset?: number): void;
  78149. /**
  78150. * Stores an UInt32 in the array buffer
  78151. * @param entry
  78152. * @param byteOffset If defined, specifies where to set the value as an offset.
  78153. */
  78154. setUInt32(entry: number, byteOffset?: number): void;
  78155. }
  78156. }
  78157. declare module BABYLON.GLTF2.Exporter {
  78158. /**
  78159. * @hidden
  78160. * Interface to store animation data.
  78161. */
  78162. export interface _IAnimationData {
  78163. /**
  78164. * Keyframe data.
  78165. */
  78166. inputs: number[];
  78167. /**
  78168. * Value data.
  78169. */
  78170. outputs: number[][];
  78171. /**
  78172. * Animation interpolation data.
  78173. */
  78174. samplerInterpolation: AnimationSamplerInterpolation;
  78175. /**
  78176. * Minimum keyframe value.
  78177. */
  78178. inputsMin: number;
  78179. /**
  78180. * Maximum keyframe value.
  78181. */
  78182. inputsMax: number;
  78183. }
  78184. /**
  78185. * @hidden
  78186. */
  78187. export interface _IAnimationInfo {
  78188. /**
  78189. * The target channel for the animation
  78190. */
  78191. animationChannelTargetPath: AnimationChannelTargetPath;
  78192. /**
  78193. * The glTF accessor type for the data.
  78194. */
  78195. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78196. /**
  78197. * Specifies if quaternions should be used.
  78198. */
  78199. useQuaternion: boolean;
  78200. }
  78201. /**
  78202. * @hidden
  78203. * Utility class for generating glTF animation data from BabylonJS.
  78204. */
  78205. export class _GLTFAnimation {
  78206. /**
  78207. * @ignore
  78208. *
  78209. * Creates glTF channel animation from BabylonJS animation.
  78210. * @param babylonTransformNode - BabylonJS mesh.
  78211. * @param animation - animation.
  78212. * @param animationChannelTargetPath - The target animation channel.
  78213. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78214. * @param useQuaternion - Specifies if quaternions are used.
  78215. * @returns nullable IAnimationData
  78216. */
  78217. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78218. private static _DeduceAnimationInfo;
  78219. /**
  78220. * @ignore
  78221. * Create node animations from the transform node animations
  78222. * @param babylonNode
  78223. * @param runtimeGLTFAnimation
  78224. * @param idleGLTFAnimations
  78225. * @param nodeMap
  78226. * @param nodes
  78227. * @param binaryWriter
  78228. * @param bufferViews
  78229. * @param accessors
  78230. * @param convertToRightHandedSystem
  78231. * @param animationSampleRate
  78232. */
  78233. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78234. [key: number]: number;
  78235. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78236. /**
  78237. * @ignore
  78238. * Create node animations from the animation groups
  78239. * @param babylonScene
  78240. * @param glTFAnimations
  78241. * @param nodeMap
  78242. * @param nodes
  78243. * @param binaryWriter
  78244. * @param bufferViews
  78245. * @param accessors
  78246. * @param convertToRightHandedSystemMap
  78247. * @param animationSampleRate
  78248. */
  78249. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78250. [key: number]: number;
  78251. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78252. [nodeId: number]: boolean;
  78253. }, animationSampleRate: number): void;
  78254. private static AddAnimation;
  78255. /**
  78256. * Create a baked animation
  78257. * @param babylonTransformNode BabylonJS mesh
  78258. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78259. * @param animationChannelTargetPath animation target channel
  78260. * @param minFrame minimum animation frame
  78261. * @param maxFrame maximum animation frame
  78262. * @param fps frames per second of the animation
  78263. * @param inputs input key frames of the animation
  78264. * @param outputs output key frame data of the animation
  78265. * @param convertToRightHandedSystem converts the values to right-handed
  78266. * @param useQuaternion specifies if quaternions should be used
  78267. */
  78268. private static _CreateBakedAnimation;
  78269. private static _ConvertFactorToVector3OrQuaternion;
  78270. private static _SetInterpolatedValue;
  78271. /**
  78272. * Creates linear animation from the animation key frames
  78273. * @param babylonTransformNode BabylonJS mesh
  78274. * @param animation BabylonJS animation
  78275. * @param animationChannelTargetPath The target animation channel
  78276. * @param frameDelta The difference between the last and first frame of the animation
  78277. * @param inputs Array to store the key frame times
  78278. * @param outputs Array to store the key frame data
  78279. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78280. * @param useQuaternion Specifies if quaternions are used in the animation
  78281. */
  78282. private static _CreateLinearOrStepAnimation;
  78283. /**
  78284. * Creates cubic spline animation from the animation key frames
  78285. * @param babylonTransformNode BabylonJS mesh
  78286. * @param animation BabylonJS animation
  78287. * @param animationChannelTargetPath The target animation channel
  78288. * @param frameDelta The difference between the last and first frame of the animation
  78289. * @param inputs Array to store the key frame times
  78290. * @param outputs Array to store the key frame data
  78291. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78292. * @param useQuaternion Specifies if quaternions are used in the animation
  78293. */
  78294. private static _CreateCubicSplineAnimation;
  78295. private static _GetBasePositionRotationOrScale;
  78296. /**
  78297. * Adds a key frame value
  78298. * @param keyFrame
  78299. * @param animation
  78300. * @param outputs
  78301. * @param animationChannelTargetPath
  78302. * @param basePositionRotationOrScale
  78303. * @param convertToRightHandedSystem
  78304. * @param useQuaternion
  78305. */
  78306. private static _AddKeyframeValue;
  78307. /**
  78308. * Determine the interpolation based on the key frames
  78309. * @param keyFrames
  78310. * @param animationChannelTargetPath
  78311. * @param useQuaternion
  78312. */
  78313. private static _DeduceInterpolation;
  78314. /**
  78315. * Adds an input tangent or output tangent to the output data
  78316. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78317. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78318. * @param outputs The animation data by keyframe
  78319. * @param animationChannelTargetPath The target animation channel
  78320. * @param interpolation The interpolation type
  78321. * @param keyFrame The key frame with the animation data
  78322. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78323. * @param useQuaternion Specifies if quaternions are used
  78324. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78325. */
  78326. private static AddSplineTangent;
  78327. /**
  78328. * Get the minimum and maximum key frames' frame values
  78329. * @param keyFrames animation key frames
  78330. * @returns the minimum and maximum key frame value
  78331. */
  78332. private static calculateMinMaxKeyFrames;
  78333. }
  78334. }
  78335. declare module BABYLON.GLTF2.Exporter {
  78336. /** @hidden */
  78337. export var textureTransformPixelShader: {
  78338. name: string;
  78339. shader: string;
  78340. };
  78341. }
  78342. declare module BABYLON.GLTF2.Exporter.Extensions {
  78343. /**
  78344. * @hidden
  78345. */
  78346. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78347. private _recordedTextures;
  78348. /** Name of this extension */
  78349. readonly name: string;
  78350. /** Defines whether this extension is enabled */
  78351. enabled: boolean;
  78352. /** Defines whether this extension is required */
  78353. required: boolean;
  78354. /** Reference to the glTF exporter */
  78355. private _wasUsed;
  78356. constructor(exporter: _Exporter);
  78357. dispose(): void;
  78358. /** @hidden */
  78359. get wasUsed(): boolean;
  78360. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78361. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78362. /**
  78363. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78364. * @param babylonTexture
  78365. * @param offset
  78366. * @param rotation
  78367. * @param scale
  78368. * @param scene
  78369. */
  78370. private _textureTransformTextureAsync;
  78371. }
  78372. }
  78373. declare module BABYLON.GLTF2.Exporter.Extensions {
  78374. /**
  78375. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78376. */
  78377. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78378. /** The name of this extension. */
  78379. readonly name: string;
  78380. /** Defines whether this extension is enabled. */
  78381. enabled: boolean;
  78382. /** Defines whether this extension is required */
  78383. required: boolean;
  78384. /** Reference to the glTF exporter */
  78385. private _exporter;
  78386. private _lights;
  78387. /** @hidden */
  78388. constructor(exporter: _Exporter);
  78389. /** @hidden */
  78390. dispose(): void;
  78391. /** @hidden */
  78392. get wasUsed(): boolean;
  78393. /** @hidden */
  78394. onExporting(): void;
  78395. /**
  78396. * Define this method to modify the default behavior when exporting a node
  78397. * @param context The context when exporting the node
  78398. * @param node glTF node
  78399. * @param babylonNode BabylonJS node
  78400. * @param nodeMap Node mapping of unique id to glTF node index
  78401. * @returns nullable INode promise
  78402. */
  78403. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78404. [key: number]: number;
  78405. }): Promise<Nullable<INode>>;
  78406. }
  78407. }
  78408. declare module BABYLON.GLTF2.Exporter.Extensions {
  78409. /**
  78410. * @hidden
  78411. */
  78412. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78413. /** Name of this extension */
  78414. readonly name: string;
  78415. /** Defines whether this extension is enabled */
  78416. enabled: boolean;
  78417. /** Defines whether this extension is required */
  78418. required: boolean;
  78419. /** Reference to the glTF exporter */
  78420. private _textureInfos;
  78421. private _exportedTextures;
  78422. private _wasUsed;
  78423. constructor(exporter: _Exporter);
  78424. dispose(): void;
  78425. /** @hidden */
  78426. get wasUsed(): boolean;
  78427. private _getTextureIndex;
  78428. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78429. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78430. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78431. }
  78432. }
  78433. declare module BABYLON {
  78434. /**
  78435. * Class for generating STL data from a Babylon scene.
  78436. */
  78437. export class STLExport {
  78438. /**
  78439. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78440. * @param meshes list defines the mesh to serialize
  78441. * @param download triggers the automatic download of the file.
  78442. * @param fileName changes the downloads fileName.
  78443. * @param binary changes the STL to a binary type.
  78444. * @param isLittleEndian toggle for binary type exporter.
  78445. * @returns the STL as UTF8 string
  78446. */
  78447. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78448. }
  78449. }
  78450. declare module "babylonjs-gltf2interface" {
  78451. export = BABYLON.GLTF2;
  78452. }
  78453. /**
  78454. * Module for glTF 2.0 Interface
  78455. */
  78456. declare module BABYLON.GLTF2 {
  78457. /**
  78458. * The datatype of the components in the attribute
  78459. */
  78460. const enum AccessorComponentType {
  78461. /**
  78462. * Byte
  78463. */
  78464. BYTE = 5120,
  78465. /**
  78466. * Unsigned Byte
  78467. */
  78468. UNSIGNED_BYTE = 5121,
  78469. /**
  78470. * Short
  78471. */
  78472. SHORT = 5122,
  78473. /**
  78474. * Unsigned Short
  78475. */
  78476. UNSIGNED_SHORT = 5123,
  78477. /**
  78478. * Unsigned Int
  78479. */
  78480. UNSIGNED_INT = 5125,
  78481. /**
  78482. * Float
  78483. */
  78484. FLOAT = 5126,
  78485. }
  78486. /**
  78487. * Specifies if the attirbute is a scalar, vector, or matrix
  78488. */
  78489. const enum AccessorType {
  78490. /**
  78491. * Scalar
  78492. */
  78493. SCALAR = "SCALAR",
  78494. /**
  78495. * Vector2
  78496. */
  78497. VEC2 = "VEC2",
  78498. /**
  78499. * Vector3
  78500. */
  78501. VEC3 = "VEC3",
  78502. /**
  78503. * Vector4
  78504. */
  78505. VEC4 = "VEC4",
  78506. /**
  78507. * Matrix2x2
  78508. */
  78509. MAT2 = "MAT2",
  78510. /**
  78511. * Matrix3x3
  78512. */
  78513. MAT3 = "MAT3",
  78514. /**
  78515. * Matrix4x4
  78516. */
  78517. MAT4 = "MAT4",
  78518. }
  78519. /**
  78520. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78521. */
  78522. const enum AnimationChannelTargetPath {
  78523. /**
  78524. * Translation
  78525. */
  78526. TRANSLATION = "translation",
  78527. /**
  78528. * Rotation
  78529. */
  78530. ROTATION = "rotation",
  78531. /**
  78532. * Scale
  78533. */
  78534. SCALE = "scale",
  78535. /**
  78536. * Weights
  78537. */
  78538. WEIGHTS = "weights",
  78539. }
  78540. /**
  78541. * Interpolation algorithm
  78542. */
  78543. const enum AnimationSamplerInterpolation {
  78544. /**
  78545. * The animated values are linearly interpolated between keyframes
  78546. */
  78547. LINEAR = "LINEAR",
  78548. /**
  78549. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78550. */
  78551. STEP = "STEP",
  78552. /**
  78553. * The animation's interpolation is computed using a cubic spline with specified tangents
  78554. */
  78555. CUBICSPLINE = "CUBICSPLINE",
  78556. }
  78557. /**
  78558. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78559. */
  78560. const enum CameraType {
  78561. /**
  78562. * A perspective camera containing properties to create a perspective projection matrix
  78563. */
  78564. PERSPECTIVE = "perspective",
  78565. /**
  78566. * An orthographic camera containing properties to create an orthographic projection matrix
  78567. */
  78568. ORTHOGRAPHIC = "orthographic",
  78569. }
  78570. /**
  78571. * The mime-type of the image
  78572. */
  78573. const enum ImageMimeType {
  78574. /**
  78575. * JPEG Mime-type
  78576. */
  78577. JPEG = "image/jpeg",
  78578. /**
  78579. * PNG Mime-type
  78580. */
  78581. PNG = "image/png",
  78582. }
  78583. /**
  78584. * The alpha rendering mode of the material
  78585. */
  78586. const enum MaterialAlphaMode {
  78587. /**
  78588. * The alpha value is ignored and the rendered output is fully opaque
  78589. */
  78590. OPAQUE = "OPAQUE",
  78591. /**
  78592. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78593. */
  78594. MASK = "MASK",
  78595. /**
  78596. * 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)
  78597. */
  78598. BLEND = "BLEND",
  78599. }
  78600. /**
  78601. * The type of the primitives to render
  78602. */
  78603. const enum MeshPrimitiveMode {
  78604. /**
  78605. * Points
  78606. */
  78607. POINTS = 0,
  78608. /**
  78609. * Lines
  78610. */
  78611. LINES = 1,
  78612. /**
  78613. * Line Loop
  78614. */
  78615. LINE_LOOP = 2,
  78616. /**
  78617. * Line Strip
  78618. */
  78619. LINE_STRIP = 3,
  78620. /**
  78621. * Triangles
  78622. */
  78623. TRIANGLES = 4,
  78624. /**
  78625. * Triangle Strip
  78626. */
  78627. TRIANGLE_STRIP = 5,
  78628. /**
  78629. * Triangle Fan
  78630. */
  78631. TRIANGLE_FAN = 6,
  78632. }
  78633. /**
  78634. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78635. */
  78636. const enum TextureMagFilter {
  78637. /**
  78638. * Nearest
  78639. */
  78640. NEAREST = 9728,
  78641. /**
  78642. * Linear
  78643. */
  78644. LINEAR = 9729,
  78645. }
  78646. /**
  78647. * Minification filter. All valid values correspond to WebGL enums
  78648. */
  78649. const enum TextureMinFilter {
  78650. /**
  78651. * Nearest
  78652. */
  78653. NEAREST = 9728,
  78654. /**
  78655. * Linear
  78656. */
  78657. LINEAR = 9729,
  78658. /**
  78659. * Nearest Mip-Map Nearest
  78660. */
  78661. NEAREST_MIPMAP_NEAREST = 9984,
  78662. /**
  78663. * Linear Mipmap Nearest
  78664. */
  78665. LINEAR_MIPMAP_NEAREST = 9985,
  78666. /**
  78667. * Nearest Mipmap Linear
  78668. */
  78669. NEAREST_MIPMAP_LINEAR = 9986,
  78670. /**
  78671. * Linear Mipmap Linear
  78672. */
  78673. LINEAR_MIPMAP_LINEAR = 9987,
  78674. }
  78675. /**
  78676. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78677. */
  78678. const enum TextureWrapMode {
  78679. /**
  78680. * Clamp to Edge
  78681. */
  78682. CLAMP_TO_EDGE = 33071,
  78683. /**
  78684. * Mirrored Repeat
  78685. */
  78686. MIRRORED_REPEAT = 33648,
  78687. /**
  78688. * Repeat
  78689. */
  78690. REPEAT = 10497,
  78691. }
  78692. /**
  78693. * glTF Property
  78694. */
  78695. interface IProperty {
  78696. /**
  78697. * Dictionary object with extension-specific objects
  78698. */
  78699. extensions?: {
  78700. [key: string]: any;
  78701. };
  78702. /**
  78703. * Application-Specific data
  78704. */
  78705. extras?: any;
  78706. }
  78707. /**
  78708. * glTF Child of Root Property
  78709. */
  78710. interface IChildRootProperty extends IProperty {
  78711. /**
  78712. * The user-defined name of this object
  78713. */
  78714. name?: string;
  78715. }
  78716. /**
  78717. * Indices of those attributes that deviate from their initialization value
  78718. */
  78719. interface IAccessorSparseIndices extends IProperty {
  78720. /**
  78721. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78722. */
  78723. bufferView: number;
  78724. /**
  78725. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78726. */
  78727. byteOffset?: number;
  78728. /**
  78729. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78730. */
  78731. componentType: AccessorComponentType;
  78732. }
  78733. /**
  78734. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78735. */
  78736. interface IAccessorSparseValues extends IProperty {
  78737. /**
  78738. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78739. */
  78740. bufferView: number;
  78741. /**
  78742. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78743. */
  78744. byteOffset?: number;
  78745. }
  78746. /**
  78747. * Sparse storage of attributes that deviate from their initialization value
  78748. */
  78749. interface IAccessorSparse extends IProperty {
  78750. /**
  78751. * The number of attributes encoded in this sparse accessor
  78752. */
  78753. count: number;
  78754. /**
  78755. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78756. */
  78757. indices: IAccessorSparseIndices;
  78758. /**
  78759. * 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
  78760. */
  78761. values: IAccessorSparseValues;
  78762. }
  78763. /**
  78764. * 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
  78765. */
  78766. interface IAccessor extends IChildRootProperty {
  78767. /**
  78768. * The index of the bufferview
  78769. */
  78770. bufferView?: number;
  78771. /**
  78772. * The offset relative to the start of the bufferView in bytes
  78773. */
  78774. byteOffset?: number;
  78775. /**
  78776. * The datatype of components in the attribute
  78777. */
  78778. componentType: AccessorComponentType;
  78779. /**
  78780. * Specifies whether integer data values should be normalized
  78781. */
  78782. normalized?: boolean;
  78783. /**
  78784. * The number of attributes referenced by this accessor
  78785. */
  78786. count: number;
  78787. /**
  78788. * Specifies if the attribute is a scalar, vector, or matrix
  78789. */
  78790. type: AccessorType;
  78791. /**
  78792. * Maximum value of each component in this attribute
  78793. */
  78794. max?: number[];
  78795. /**
  78796. * Minimum value of each component in this attribute
  78797. */
  78798. min?: number[];
  78799. /**
  78800. * Sparse storage of attributes that deviate from their initialization value
  78801. */
  78802. sparse?: IAccessorSparse;
  78803. }
  78804. /**
  78805. * Targets an animation's sampler at a node's property
  78806. */
  78807. interface IAnimationChannel extends IProperty {
  78808. /**
  78809. * The index of a sampler in this animation used to compute the value for the target
  78810. */
  78811. sampler: number;
  78812. /**
  78813. * The index of the node and TRS property to target
  78814. */
  78815. target: IAnimationChannelTarget;
  78816. }
  78817. /**
  78818. * The index of the node and TRS property that an animation channel targets
  78819. */
  78820. interface IAnimationChannelTarget extends IProperty {
  78821. /**
  78822. * The index of the node to target
  78823. */
  78824. node: number;
  78825. /**
  78826. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78827. */
  78828. path: AnimationChannelTargetPath;
  78829. }
  78830. /**
  78831. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78832. */
  78833. interface IAnimationSampler extends IProperty {
  78834. /**
  78835. * The index of an accessor containing keyframe input values, e.g., time
  78836. */
  78837. input: number;
  78838. /**
  78839. * Interpolation algorithm
  78840. */
  78841. interpolation?: AnimationSamplerInterpolation;
  78842. /**
  78843. * The index of an accessor, containing keyframe output values
  78844. */
  78845. output: number;
  78846. }
  78847. /**
  78848. * A keyframe animation
  78849. */
  78850. interface IAnimation extends IChildRootProperty {
  78851. /**
  78852. * An array of channels, each of which targets an animation's sampler at a node's property
  78853. */
  78854. channels: IAnimationChannel[];
  78855. /**
  78856. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78857. */
  78858. samplers: IAnimationSampler[];
  78859. }
  78860. /**
  78861. * Metadata about the glTF asset
  78862. */
  78863. interface IAsset extends IChildRootProperty {
  78864. /**
  78865. * A copyright message suitable for display to credit the content creator
  78866. */
  78867. copyright?: string;
  78868. /**
  78869. * Tool that generated this glTF model. Useful for debugging
  78870. */
  78871. generator?: string;
  78872. /**
  78873. * The glTF version that this asset targets
  78874. */
  78875. version: string;
  78876. /**
  78877. * The minimum glTF version that this asset targets
  78878. */
  78879. minVersion?: string;
  78880. }
  78881. /**
  78882. * A buffer points to binary geometry, animation, or skins
  78883. */
  78884. interface IBuffer extends IChildRootProperty {
  78885. /**
  78886. * 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
  78887. */
  78888. uri?: string;
  78889. /**
  78890. * The length of the buffer in bytes
  78891. */
  78892. byteLength: number;
  78893. }
  78894. /**
  78895. * A view into a buffer generally representing a subset of the buffer
  78896. */
  78897. interface IBufferView extends IChildRootProperty {
  78898. /**
  78899. * The index of the buffer
  78900. */
  78901. buffer: number;
  78902. /**
  78903. * The offset into the buffer in bytes
  78904. */
  78905. byteOffset?: number;
  78906. /**
  78907. * The lenth of the bufferView in bytes
  78908. */
  78909. byteLength: number;
  78910. /**
  78911. * The stride, in bytes
  78912. */
  78913. byteStride?: number;
  78914. }
  78915. /**
  78916. * An orthographic camera containing properties to create an orthographic projection matrix
  78917. */
  78918. interface ICameraOrthographic extends IProperty {
  78919. /**
  78920. * The floating-point horizontal magnification of the view. Must not be zero
  78921. */
  78922. xmag: number;
  78923. /**
  78924. * The floating-point vertical magnification of the view. Must not be zero
  78925. */
  78926. ymag: number;
  78927. /**
  78928. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78929. */
  78930. zfar: number;
  78931. /**
  78932. * The floating-point distance to the near clipping plane
  78933. */
  78934. znear: number;
  78935. }
  78936. /**
  78937. * A perspective camera containing properties to create a perspective projection matrix
  78938. */
  78939. interface ICameraPerspective extends IProperty {
  78940. /**
  78941. * The floating-point aspect ratio of the field of view
  78942. */
  78943. aspectRatio?: number;
  78944. /**
  78945. * The floating-point vertical field of view in radians
  78946. */
  78947. yfov: number;
  78948. /**
  78949. * The floating-point distance to the far clipping plane
  78950. */
  78951. zfar?: number;
  78952. /**
  78953. * The floating-point distance to the near clipping plane
  78954. */
  78955. znear: number;
  78956. }
  78957. /**
  78958. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78959. */
  78960. interface ICamera extends IChildRootProperty {
  78961. /**
  78962. * An orthographic camera containing properties to create an orthographic projection matrix
  78963. */
  78964. orthographic?: ICameraOrthographic;
  78965. /**
  78966. * A perspective camera containing properties to create a perspective projection matrix
  78967. */
  78968. perspective?: ICameraPerspective;
  78969. /**
  78970. * Specifies if the camera uses a perspective or orthographic projection
  78971. */
  78972. type: CameraType;
  78973. }
  78974. /**
  78975. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78976. */
  78977. interface IImage extends IChildRootProperty {
  78978. /**
  78979. * 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
  78980. */
  78981. uri?: string;
  78982. /**
  78983. * The image's MIME type
  78984. */
  78985. mimeType?: ImageMimeType;
  78986. /**
  78987. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78988. */
  78989. bufferView?: number;
  78990. }
  78991. /**
  78992. * Material Normal Texture Info
  78993. */
  78994. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78995. /**
  78996. * The scalar multiplier applied to each normal vector of the normal texture
  78997. */
  78998. scale?: number;
  78999. }
  79000. /**
  79001. * Material Occlusion Texture Info
  79002. */
  79003. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79004. /**
  79005. * A scalar multiplier controlling the amount of occlusion applied
  79006. */
  79007. strength?: number;
  79008. }
  79009. /**
  79010. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79011. */
  79012. interface IMaterialPbrMetallicRoughness {
  79013. /**
  79014. * The material's base color factor
  79015. */
  79016. baseColorFactor?: number[];
  79017. /**
  79018. * The base color texture
  79019. */
  79020. baseColorTexture?: ITextureInfo;
  79021. /**
  79022. * The metalness of the material
  79023. */
  79024. metallicFactor?: number;
  79025. /**
  79026. * The roughness of the material
  79027. */
  79028. roughnessFactor?: number;
  79029. /**
  79030. * The metallic-roughness texture
  79031. */
  79032. metallicRoughnessTexture?: ITextureInfo;
  79033. }
  79034. /**
  79035. * The material appearance of a primitive
  79036. */
  79037. interface IMaterial extends IChildRootProperty {
  79038. /**
  79039. * 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
  79040. */
  79041. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79042. /**
  79043. * The normal map texture
  79044. */
  79045. normalTexture?: IMaterialNormalTextureInfo;
  79046. /**
  79047. * The occlusion map texture
  79048. */
  79049. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79050. /**
  79051. * The emissive map texture
  79052. */
  79053. emissiveTexture?: ITextureInfo;
  79054. /**
  79055. * 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
  79056. */
  79057. emissiveFactor?: number[];
  79058. /**
  79059. * The alpha rendering mode of the material
  79060. */
  79061. alphaMode?: MaterialAlphaMode;
  79062. /**
  79063. * The alpha cutoff value of the material
  79064. */
  79065. alphaCutoff?: number;
  79066. /**
  79067. * Specifies whether the material is double sided
  79068. */
  79069. doubleSided?: boolean;
  79070. }
  79071. /**
  79072. * Geometry to be rendered with the given material
  79073. */
  79074. interface IMeshPrimitive extends IProperty {
  79075. /**
  79076. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79077. */
  79078. attributes: {
  79079. [name: string]: number;
  79080. };
  79081. /**
  79082. * The index of the accessor that contains the indices
  79083. */
  79084. indices?: number;
  79085. /**
  79086. * The index of the material to apply to this primitive when rendering
  79087. */
  79088. material?: number;
  79089. /**
  79090. * The type of primitives to render. All valid values correspond to WebGL enums
  79091. */
  79092. mode?: MeshPrimitiveMode;
  79093. /**
  79094. * 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
  79095. */
  79096. targets?: {
  79097. [name: string]: number;
  79098. }[];
  79099. }
  79100. /**
  79101. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79102. */
  79103. interface IMesh extends IChildRootProperty {
  79104. /**
  79105. * An array of primitives, each defining geometry to be rendered with a material
  79106. */
  79107. primitives: IMeshPrimitive[];
  79108. /**
  79109. * Array of weights to be applied to the Morph Targets
  79110. */
  79111. weights?: number[];
  79112. }
  79113. /**
  79114. * A node in the node hierarchy
  79115. */
  79116. interface INode extends IChildRootProperty {
  79117. /**
  79118. * The index of the camera referenced by this node
  79119. */
  79120. camera?: number;
  79121. /**
  79122. * The indices of this node's children
  79123. */
  79124. children?: number[];
  79125. /**
  79126. * The index of the skin referenced by this node
  79127. */
  79128. skin?: number;
  79129. /**
  79130. * A floating-point 4x4 transformation matrix stored in column-major order
  79131. */
  79132. matrix?: number[];
  79133. /**
  79134. * The index of the mesh in this node
  79135. */
  79136. mesh?: number;
  79137. /**
  79138. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79139. */
  79140. rotation?: number[];
  79141. /**
  79142. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79143. */
  79144. scale?: number[];
  79145. /**
  79146. * The node's translation along the x, y, and z axes
  79147. */
  79148. translation?: number[];
  79149. /**
  79150. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79151. */
  79152. weights?: number[];
  79153. }
  79154. /**
  79155. * Texture sampler properties for filtering and wrapping modes
  79156. */
  79157. interface ISampler extends IChildRootProperty {
  79158. /**
  79159. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79160. */
  79161. magFilter?: TextureMagFilter;
  79162. /**
  79163. * Minification filter. All valid values correspond to WebGL enums
  79164. */
  79165. minFilter?: TextureMinFilter;
  79166. /**
  79167. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79168. */
  79169. wrapS?: TextureWrapMode;
  79170. /**
  79171. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79172. */
  79173. wrapT?: TextureWrapMode;
  79174. }
  79175. /**
  79176. * The root nodes of a scene
  79177. */
  79178. interface IScene extends IChildRootProperty {
  79179. /**
  79180. * The indices of each root node
  79181. */
  79182. nodes: number[];
  79183. }
  79184. /**
  79185. * Joints and matrices defining a skin
  79186. */
  79187. interface ISkin extends IChildRootProperty {
  79188. /**
  79189. * 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
  79190. */
  79191. inverseBindMatrices?: number;
  79192. /**
  79193. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79194. */
  79195. skeleton?: number;
  79196. /**
  79197. * 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)
  79198. */
  79199. joints: number[];
  79200. }
  79201. /**
  79202. * A texture and its sampler
  79203. */
  79204. interface ITexture extends IChildRootProperty {
  79205. /**
  79206. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79207. */
  79208. sampler?: number;
  79209. /**
  79210. * The index of the image used by this texture
  79211. */
  79212. source: number;
  79213. }
  79214. /**
  79215. * Reference to a texture
  79216. */
  79217. interface ITextureInfo extends IProperty {
  79218. /**
  79219. * The index of the texture
  79220. */
  79221. index: number;
  79222. /**
  79223. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79224. */
  79225. texCoord?: number;
  79226. }
  79227. /**
  79228. * The root object for a glTF asset
  79229. */
  79230. interface IGLTF extends IProperty {
  79231. /**
  79232. * An array of accessors. An accessor is a typed view into a bufferView
  79233. */
  79234. accessors?: IAccessor[];
  79235. /**
  79236. * An array of keyframe animations
  79237. */
  79238. animations?: IAnimation[];
  79239. /**
  79240. * Metadata about the glTF asset
  79241. */
  79242. asset: IAsset;
  79243. /**
  79244. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79245. */
  79246. buffers?: IBuffer[];
  79247. /**
  79248. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79249. */
  79250. bufferViews?: IBufferView[];
  79251. /**
  79252. * An array of cameras
  79253. */
  79254. cameras?: ICamera[];
  79255. /**
  79256. * Names of glTF extensions used somewhere in this asset
  79257. */
  79258. extensionsUsed?: string[];
  79259. /**
  79260. * Names of glTF extensions required to properly load this asset
  79261. */
  79262. extensionsRequired?: string[];
  79263. /**
  79264. * An array of images. An image defines data used to create a texture
  79265. */
  79266. images?: IImage[];
  79267. /**
  79268. * An array of materials. A material defines the appearance of a primitive
  79269. */
  79270. materials?: IMaterial[];
  79271. /**
  79272. * An array of meshes. A mesh is a set of primitives to be rendered
  79273. */
  79274. meshes?: IMesh[];
  79275. /**
  79276. * An array of nodes
  79277. */
  79278. nodes?: INode[];
  79279. /**
  79280. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79281. */
  79282. samplers?: ISampler[];
  79283. /**
  79284. * The index of the default scene
  79285. */
  79286. scene?: number;
  79287. /**
  79288. * An array of scenes
  79289. */
  79290. scenes?: IScene[];
  79291. /**
  79292. * An array of skins. A skin is defined by joints and matrices
  79293. */
  79294. skins?: ISkin[];
  79295. /**
  79296. * An array of textures
  79297. */
  79298. textures?: ITexture[];
  79299. }
  79300. /**
  79301. * The glTF validation results
  79302. * @ignore
  79303. */
  79304. interface IGLTFValidationResults {
  79305. info: {
  79306. generator: string;
  79307. hasAnimations: boolean;
  79308. hasDefaultScene: boolean;
  79309. hasMaterials: boolean;
  79310. hasMorphTargets: boolean;
  79311. hasSkins: boolean;
  79312. hasTextures: boolean;
  79313. maxAttributesUsed: number;
  79314. primitivesCount: number
  79315. };
  79316. issues: {
  79317. messages: Array<string>;
  79318. numErrors: number;
  79319. numHints: number;
  79320. numInfos: number;
  79321. numWarnings: number;
  79322. truncated: boolean
  79323. };
  79324. mimeType: string;
  79325. uri: string;
  79326. validatedAt: string;
  79327. validatorVersion: string;
  79328. }
  79329. /**
  79330. * The glTF validation options
  79331. */
  79332. interface IGLTFValidationOptions {
  79333. /** Uri to use */
  79334. uri?: string;
  79335. /** Function used to load external resources */
  79336. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79337. /** Boolean indicating that we need to validate accessor data */
  79338. validateAccessorData?: boolean;
  79339. /** max number of issues allowed */
  79340. maxIssues?: number;
  79341. /** Ignored issues */
  79342. ignoredIssues?: Array<string>;
  79343. /** Value to override severy settings */
  79344. severityOverrides?: Object;
  79345. }
  79346. /**
  79347. * The glTF validator object
  79348. * @ignore
  79349. */
  79350. interface IGLTFValidator {
  79351. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79352. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79353. }
  79354. }
  79355. declare module BABYLON {
  79356. /** @hidden */
  79357. export var cellPixelShader: {
  79358. name: string;
  79359. shader: string;
  79360. };
  79361. }
  79362. declare module BABYLON {
  79363. /** @hidden */
  79364. export var cellVertexShader: {
  79365. name: string;
  79366. shader: string;
  79367. };
  79368. }
  79369. declare module BABYLON {
  79370. export class CellMaterial extends BABYLON.PushMaterial {
  79371. private _diffuseTexture;
  79372. diffuseTexture: BABYLON.BaseTexture;
  79373. diffuseColor: BABYLON.Color3;
  79374. _computeHighLevel: boolean;
  79375. computeHighLevel: boolean;
  79376. private _disableLighting;
  79377. disableLighting: boolean;
  79378. private _maxSimultaneousLights;
  79379. maxSimultaneousLights: number;
  79380. private _renderId;
  79381. constructor(name: string, scene: BABYLON.Scene);
  79382. needAlphaBlending(): boolean;
  79383. needAlphaTesting(): boolean;
  79384. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79385. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79386. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79387. getAnimatables(): BABYLON.IAnimatable[];
  79388. getActiveTextures(): BABYLON.BaseTexture[];
  79389. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79390. dispose(forceDisposeEffect?: boolean): void;
  79391. getClassName(): string;
  79392. clone(name: string): CellMaterial;
  79393. serialize(): any;
  79394. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79395. }
  79396. }
  79397. declare module BABYLON {
  79398. export class CustomShaderStructure {
  79399. FragmentStore: string;
  79400. VertexStore: string;
  79401. constructor();
  79402. }
  79403. export class ShaderSpecialParts {
  79404. constructor();
  79405. Fragment_Begin: string;
  79406. Fragment_Definitions: string;
  79407. Fragment_MainBegin: string;
  79408. Fragment_Custom_Diffuse: string;
  79409. Fragment_Before_Lights: string;
  79410. Fragment_Before_Fog: string;
  79411. Fragment_Custom_Alpha: string;
  79412. Fragment_Before_FragColor: string;
  79413. Vertex_Begin: string;
  79414. Vertex_Definitions: string;
  79415. Vertex_MainBegin: string;
  79416. Vertex_Before_PositionUpdated: string;
  79417. Vertex_Before_NormalUpdated: string;
  79418. Vertex_MainEnd: string;
  79419. }
  79420. export class CustomMaterial extends BABYLON.StandardMaterial {
  79421. static ShaderIndexer: number;
  79422. CustomParts: ShaderSpecialParts;
  79423. _isCreatedShader: boolean;
  79424. _createdShaderName: string;
  79425. _customUniform: string[];
  79426. _newUniforms: string[];
  79427. _newUniformInstances: any[];
  79428. _newSamplerInstances: BABYLON.Texture[];
  79429. _customAttributes: string[];
  79430. FragmentShader: string;
  79431. VertexShader: string;
  79432. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79433. ReviewUniform(name: string, arr: string[]): string[];
  79434. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79435. constructor(name: string, scene: BABYLON.Scene);
  79436. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79437. AddAttribute(name: string): CustomMaterial;
  79438. Fragment_Begin(shaderPart: string): CustomMaterial;
  79439. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79440. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79441. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79442. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79443. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79444. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79445. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79446. Vertex_Begin(shaderPart: string): CustomMaterial;
  79447. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79448. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79449. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79450. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79451. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79452. }
  79453. }
  79454. declare module BABYLON {
  79455. export class ShaderAlebdoParts {
  79456. constructor();
  79457. Fragment_Begin: string;
  79458. Fragment_Definitions: string;
  79459. Fragment_MainBegin: string;
  79460. Fragment_Custom_Albedo: string;
  79461. Fragment_Before_Lights: string;
  79462. Fragment_Custom_MetallicRoughness: string;
  79463. Fragment_Custom_MicroSurface: string;
  79464. Fragment_Before_Fog: string;
  79465. Fragment_Custom_Alpha: string;
  79466. Fragment_Before_FragColor: string;
  79467. Vertex_Begin: string;
  79468. Vertex_Definitions: string;
  79469. Vertex_MainBegin: string;
  79470. Vertex_Before_PositionUpdated: string;
  79471. Vertex_Before_NormalUpdated: string;
  79472. Vertex_MainEnd: string;
  79473. }
  79474. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79475. static ShaderIndexer: number;
  79476. CustomParts: ShaderAlebdoParts;
  79477. _isCreatedShader: boolean;
  79478. _createdShaderName: string;
  79479. _customUniform: string[];
  79480. _newUniforms: string[];
  79481. _newUniformInstances: any[];
  79482. _newSamplerInstances: BABYLON.Texture[];
  79483. _customAttributes: string[];
  79484. FragmentShader: string;
  79485. VertexShader: string;
  79486. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79487. ReviewUniform(name: string, arr: string[]): string[];
  79488. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79489. constructor(name: string, scene: BABYLON.Scene);
  79490. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79491. AddAttribute(name: string): PBRCustomMaterial;
  79492. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79493. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79494. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79495. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79496. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79497. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79498. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79499. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79500. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79501. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79502. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79503. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79504. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79505. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79506. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79507. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79508. }
  79509. }
  79510. declare module BABYLON {
  79511. /** @hidden */
  79512. export var firePixelShader: {
  79513. name: string;
  79514. shader: string;
  79515. };
  79516. }
  79517. declare module BABYLON {
  79518. /** @hidden */
  79519. export var fireVertexShader: {
  79520. name: string;
  79521. shader: string;
  79522. };
  79523. }
  79524. declare module BABYLON {
  79525. export class FireMaterial extends BABYLON.PushMaterial {
  79526. private _diffuseTexture;
  79527. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79528. private _distortionTexture;
  79529. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79530. private _opacityTexture;
  79531. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79532. diffuseColor: BABYLON.Color3;
  79533. speed: number;
  79534. private _scaledDiffuse;
  79535. private _renderId;
  79536. private _lastTime;
  79537. constructor(name: string, scene: BABYLON.Scene);
  79538. needAlphaBlending(): boolean;
  79539. needAlphaTesting(): boolean;
  79540. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79541. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79542. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79543. getAnimatables(): BABYLON.IAnimatable[];
  79544. getActiveTextures(): BABYLON.BaseTexture[];
  79545. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79546. getClassName(): string;
  79547. dispose(forceDisposeEffect?: boolean): void;
  79548. clone(name: string): FireMaterial;
  79549. serialize(): any;
  79550. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79551. }
  79552. }
  79553. declare module BABYLON {
  79554. /** @hidden */
  79555. export var furPixelShader: {
  79556. name: string;
  79557. shader: string;
  79558. };
  79559. }
  79560. declare module BABYLON {
  79561. /** @hidden */
  79562. export var furVertexShader: {
  79563. name: string;
  79564. shader: string;
  79565. };
  79566. }
  79567. declare module BABYLON {
  79568. export class FurMaterial extends BABYLON.PushMaterial {
  79569. private _diffuseTexture;
  79570. diffuseTexture: BABYLON.BaseTexture;
  79571. private _heightTexture;
  79572. heightTexture: BABYLON.BaseTexture;
  79573. diffuseColor: BABYLON.Color3;
  79574. furLength: number;
  79575. furAngle: number;
  79576. furColor: BABYLON.Color3;
  79577. furOffset: number;
  79578. furSpacing: number;
  79579. furGravity: BABYLON.Vector3;
  79580. furSpeed: number;
  79581. furDensity: number;
  79582. furOcclusion: number;
  79583. furTexture: BABYLON.DynamicTexture;
  79584. private _disableLighting;
  79585. disableLighting: boolean;
  79586. private _maxSimultaneousLights;
  79587. maxSimultaneousLights: number;
  79588. highLevelFur: boolean;
  79589. _meshes: BABYLON.AbstractMesh[];
  79590. private _renderId;
  79591. private _furTime;
  79592. constructor(name: string, scene: BABYLON.Scene);
  79593. get furTime(): number;
  79594. set furTime(furTime: number);
  79595. needAlphaBlending(): boolean;
  79596. needAlphaTesting(): boolean;
  79597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79598. updateFur(): void;
  79599. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79600. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79601. getAnimatables(): BABYLON.IAnimatable[];
  79602. getActiveTextures(): BABYLON.BaseTexture[];
  79603. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79604. dispose(forceDisposeEffect?: boolean): void;
  79605. clone(name: string): FurMaterial;
  79606. serialize(): any;
  79607. getClassName(): string;
  79608. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79609. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79610. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79611. }
  79612. }
  79613. declare module BABYLON {
  79614. /** @hidden */
  79615. export var gradientPixelShader: {
  79616. name: string;
  79617. shader: string;
  79618. };
  79619. }
  79620. declare module BABYLON {
  79621. /** @hidden */
  79622. export var gradientVertexShader: {
  79623. name: string;
  79624. shader: string;
  79625. };
  79626. }
  79627. declare module BABYLON {
  79628. export class GradientMaterial extends BABYLON.PushMaterial {
  79629. private _maxSimultaneousLights;
  79630. maxSimultaneousLights: number;
  79631. topColor: BABYLON.Color3;
  79632. topColorAlpha: number;
  79633. bottomColor: BABYLON.Color3;
  79634. bottomColorAlpha: number;
  79635. offset: number;
  79636. scale: number;
  79637. smoothness: number;
  79638. private _disableLighting;
  79639. disableLighting: boolean;
  79640. private _renderId;
  79641. constructor(name: string, scene: BABYLON.Scene);
  79642. needAlphaBlending(): boolean;
  79643. needAlphaTesting(): boolean;
  79644. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79645. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79646. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79647. getAnimatables(): BABYLON.IAnimatable[];
  79648. dispose(forceDisposeEffect?: boolean): void;
  79649. clone(name: string): GradientMaterial;
  79650. serialize(): any;
  79651. getClassName(): string;
  79652. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79653. }
  79654. }
  79655. declare module BABYLON {
  79656. /** @hidden */
  79657. export var gridPixelShader: {
  79658. name: string;
  79659. shader: string;
  79660. };
  79661. }
  79662. declare module BABYLON {
  79663. /** @hidden */
  79664. export var gridVertexShader: {
  79665. name: string;
  79666. shader: string;
  79667. };
  79668. }
  79669. declare module BABYLON {
  79670. /**
  79671. * The grid materials allows you to wrap any shape with a grid.
  79672. * Colors are customizable.
  79673. */
  79674. export class GridMaterial extends BABYLON.PushMaterial {
  79675. /**
  79676. * Main color of the grid (e.g. between lines)
  79677. */
  79678. mainColor: BABYLON.Color3;
  79679. /**
  79680. * Color of the grid lines.
  79681. */
  79682. lineColor: BABYLON.Color3;
  79683. /**
  79684. * The scale of the grid compared to unit.
  79685. */
  79686. gridRatio: number;
  79687. /**
  79688. * Allows setting an offset for the grid lines.
  79689. */
  79690. gridOffset: BABYLON.Vector3;
  79691. /**
  79692. * The frequency of thicker lines.
  79693. */
  79694. majorUnitFrequency: number;
  79695. /**
  79696. * The visibility of minor units in the grid.
  79697. */
  79698. minorUnitVisibility: number;
  79699. /**
  79700. * The grid opacity outside of the lines.
  79701. */
  79702. opacity: number;
  79703. /**
  79704. * Determine RBG output is premultiplied by alpha value.
  79705. */
  79706. preMultiplyAlpha: boolean;
  79707. private _opacityTexture;
  79708. opacityTexture: BABYLON.BaseTexture;
  79709. private _gridControl;
  79710. private _renderId;
  79711. /**
  79712. * constructor
  79713. * @param name The name given to the material in order to identify it afterwards.
  79714. * @param scene The scene the material is used in.
  79715. */
  79716. constructor(name: string, scene: BABYLON.Scene);
  79717. /**
  79718. * Returns wehter or not the grid requires alpha blending.
  79719. */
  79720. needAlphaBlending(): boolean;
  79721. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79722. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79723. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79724. /**
  79725. * Dispose the material and its associated resources.
  79726. * @param forceDisposeEffect will also dispose the used effect when true
  79727. */
  79728. dispose(forceDisposeEffect?: boolean): void;
  79729. clone(name: string): GridMaterial;
  79730. serialize(): any;
  79731. getClassName(): string;
  79732. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79733. }
  79734. }
  79735. declare module BABYLON {
  79736. /** @hidden */
  79737. export var lavaPixelShader: {
  79738. name: string;
  79739. shader: string;
  79740. };
  79741. }
  79742. declare module BABYLON {
  79743. /** @hidden */
  79744. export var lavaVertexShader: {
  79745. name: string;
  79746. shader: string;
  79747. };
  79748. }
  79749. declare module BABYLON {
  79750. export class LavaMaterial extends BABYLON.PushMaterial {
  79751. private _diffuseTexture;
  79752. diffuseTexture: BABYLON.BaseTexture;
  79753. noiseTexture: BABYLON.BaseTexture;
  79754. fogColor: BABYLON.Color3;
  79755. speed: number;
  79756. movingSpeed: number;
  79757. lowFrequencySpeed: number;
  79758. fogDensity: number;
  79759. private _lastTime;
  79760. diffuseColor: BABYLON.Color3;
  79761. private _disableLighting;
  79762. disableLighting: boolean;
  79763. private _unlit;
  79764. unlit: boolean;
  79765. private _maxSimultaneousLights;
  79766. maxSimultaneousLights: number;
  79767. private _scaledDiffuse;
  79768. private _renderId;
  79769. constructor(name: string, scene: BABYLON.Scene);
  79770. needAlphaBlending(): boolean;
  79771. needAlphaTesting(): boolean;
  79772. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79773. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79774. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79775. getAnimatables(): BABYLON.IAnimatable[];
  79776. getActiveTextures(): BABYLON.BaseTexture[];
  79777. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79778. dispose(forceDisposeEffect?: boolean): void;
  79779. clone(name: string): LavaMaterial;
  79780. serialize(): any;
  79781. getClassName(): string;
  79782. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79783. }
  79784. }
  79785. declare module BABYLON {
  79786. /** @hidden */
  79787. export var mixPixelShader: {
  79788. name: string;
  79789. shader: string;
  79790. };
  79791. }
  79792. declare module BABYLON {
  79793. /** @hidden */
  79794. export var mixVertexShader: {
  79795. name: string;
  79796. shader: string;
  79797. };
  79798. }
  79799. declare module BABYLON {
  79800. export class MixMaterial extends BABYLON.PushMaterial {
  79801. /**
  79802. * Mix textures
  79803. */
  79804. private _mixTexture1;
  79805. mixTexture1: BABYLON.BaseTexture;
  79806. private _mixTexture2;
  79807. mixTexture2: BABYLON.BaseTexture;
  79808. /**
  79809. * Diffuse textures
  79810. */
  79811. private _diffuseTexture1;
  79812. diffuseTexture1: BABYLON.Texture;
  79813. private _diffuseTexture2;
  79814. diffuseTexture2: BABYLON.Texture;
  79815. private _diffuseTexture3;
  79816. diffuseTexture3: BABYLON.Texture;
  79817. private _diffuseTexture4;
  79818. diffuseTexture4: BABYLON.Texture;
  79819. private _diffuseTexture5;
  79820. diffuseTexture5: BABYLON.Texture;
  79821. private _diffuseTexture6;
  79822. diffuseTexture6: BABYLON.Texture;
  79823. private _diffuseTexture7;
  79824. diffuseTexture7: BABYLON.Texture;
  79825. private _diffuseTexture8;
  79826. diffuseTexture8: BABYLON.Texture;
  79827. /**
  79828. * Uniforms
  79829. */
  79830. diffuseColor: BABYLON.Color3;
  79831. specularColor: BABYLON.Color3;
  79832. specularPower: number;
  79833. private _disableLighting;
  79834. disableLighting: boolean;
  79835. private _maxSimultaneousLights;
  79836. maxSimultaneousLights: number;
  79837. private _renderId;
  79838. constructor(name: string, scene: BABYLON.Scene);
  79839. needAlphaBlending(): boolean;
  79840. needAlphaTesting(): boolean;
  79841. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79842. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79843. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79844. getAnimatables(): BABYLON.IAnimatable[];
  79845. getActiveTextures(): BABYLON.BaseTexture[];
  79846. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79847. dispose(forceDisposeEffect?: boolean): void;
  79848. clone(name: string): MixMaterial;
  79849. serialize(): any;
  79850. getClassName(): string;
  79851. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79852. }
  79853. }
  79854. declare module BABYLON {
  79855. /** @hidden */
  79856. export var normalPixelShader: {
  79857. name: string;
  79858. shader: string;
  79859. };
  79860. }
  79861. declare module BABYLON {
  79862. /** @hidden */
  79863. export var normalVertexShader: {
  79864. name: string;
  79865. shader: string;
  79866. };
  79867. }
  79868. declare module BABYLON {
  79869. export class NormalMaterial extends BABYLON.PushMaterial {
  79870. private _diffuseTexture;
  79871. diffuseTexture: BABYLON.BaseTexture;
  79872. diffuseColor: BABYLON.Color3;
  79873. private _disableLighting;
  79874. disableLighting: boolean;
  79875. private _maxSimultaneousLights;
  79876. maxSimultaneousLights: number;
  79877. private _renderId;
  79878. constructor(name: string, scene: BABYLON.Scene);
  79879. needAlphaBlending(): boolean;
  79880. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79881. needAlphaTesting(): boolean;
  79882. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79883. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79884. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79885. getAnimatables(): BABYLON.IAnimatable[];
  79886. getActiveTextures(): BABYLON.BaseTexture[];
  79887. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79888. dispose(forceDisposeEffect?: boolean): void;
  79889. clone(name: string): NormalMaterial;
  79890. serialize(): any;
  79891. getClassName(): string;
  79892. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79893. }
  79894. }
  79895. declare module BABYLON {
  79896. /** @hidden */
  79897. export var shadowOnlyPixelShader: {
  79898. name: string;
  79899. shader: string;
  79900. };
  79901. }
  79902. declare module BABYLON {
  79903. /** @hidden */
  79904. export var shadowOnlyVertexShader: {
  79905. name: string;
  79906. shader: string;
  79907. };
  79908. }
  79909. declare module BABYLON {
  79910. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79911. private _renderId;
  79912. private _activeLight;
  79913. constructor(name: string, scene: BABYLON.Scene);
  79914. shadowColor: BABYLON.Color3;
  79915. needAlphaBlending(): boolean;
  79916. needAlphaTesting(): boolean;
  79917. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79918. get activeLight(): BABYLON.IShadowLight;
  79919. set activeLight(light: BABYLON.IShadowLight);
  79920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79922. clone(name: string): ShadowOnlyMaterial;
  79923. serialize(): any;
  79924. getClassName(): string;
  79925. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79926. }
  79927. }
  79928. declare module BABYLON {
  79929. /** @hidden */
  79930. export var simplePixelShader: {
  79931. name: string;
  79932. shader: string;
  79933. };
  79934. }
  79935. declare module BABYLON {
  79936. /** @hidden */
  79937. export var simpleVertexShader: {
  79938. name: string;
  79939. shader: string;
  79940. };
  79941. }
  79942. declare module BABYLON {
  79943. export class SimpleMaterial extends BABYLON.PushMaterial {
  79944. private _diffuseTexture;
  79945. diffuseTexture: BABYLON.BaseTexture;
  79946. diffuseColor: BABYLON.Color3;
  79947. private _disableLighting;
  79948. disableLighting: boolean;
  79949. private _maxSimultaneousLights;
  79950. maxSimultaneousLights: number;
  79951. private _renderId;
  79952. constructor(name: string, scene: BABYLON.Scene);
  79953. needAlphaBlending(): boolean;
  79954. needAlphaTesting(): boolean;
  79955. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79956. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79957. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79958. getAnimatables(): BABYLON.IAnimatable[];
  79959. getActiveTextures(): BABYLON.BaseTexture[];
  79960. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79961. dispose(forceDisposeEffect?: boolean): void;
  79962. clone(name: string): SimpleMaterial;
  79963. serialize(): any;
  79964. getClassName(): string;
  79965. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79966. }
  79967. }
  79968. declare module BABYLON {
  79969. /** @hidden */
  79970. export var skyPixelShader: {
  79971. name: string;
  79972. shader: string;
  79973. };
  79974. }
  79975. declare module BABYLON {
  79976. /** @hidden */
  79977. export var skyVertexShader: {
  79978. name: string;
  79979. shader: string;
  79980. };
  79981. }
  79982. declare module BABYLON {
  79983. /**
  79984. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79985. * @see https://doc.babylonjs.com/extensions/sky
  79986. */
  79987. export class SkyMaterial extends BABYLON.PushMaterial {
  79988. /**
  79989. * Defines the overall luminance of sky in interval ]0, 1[.
  79990. */
  79991. luminance: number;
  79992. /**
  79993. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79994. */
  79995. turbidity: number;
  79996. /**
  79997. * Defines the sky appearance (light intensity).
  79998. */
  79999. rayleigh: number;
  80000. /**
  80001. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80002. */
  80003. mieCoefficient: number;
  80004. /**
  80005. * Defines the amount of haze particles following the Mie scattering theory.
  80006. */
  80007. mieDirectionalG: number;
  80008. /**
  80009. * Defines the distance of the sun according to the active scene camera.
  80010. */
  80011. distance: number;
  80012. /**
  80013. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80014. * "inclined".
  80015. */
  80016. inclination: number;
  80017. /**
  80018. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80019. * an object direction and a reference direction.
  80020. */
  80021. azimuth: number;
  80022. /**
  80023. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80024. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80025. */
  80026. sunPosition: BABYLON.Vector3;
  80027. /**
  80028. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80029. * .sunPosition property.
  80030. */
  80031. useSunPosition: boolean;
  80032. /**
  80033. * Defines an offset vector used to get a horizon offset.
  80034. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80035. */
  80036. cameraOffset: BABYLON.Vector3;
  80037. private _cameraPosition;
  80038. private _renderId;
  80039. /**
  80040. * Instantiates a new sky material.
  80041. * This material allows to create dynamic and texture free
  80042. * effects for skyboxes by taking care of the atmosphere state.
  80043. * @see https://doc.babylonjs.com/extensions/sky
  80044. * @param name Define the name of the material in the scene
  80045. * @param scene Define the scene the material belong to
  80046. */
  80047. constructor(name: string, scene: BABYLON.Scene);
  80048. /**
  80049. * Specifies if the material will require alpha blending
  80050. * @returns a boolean specifying if alpha blending is needed
  80051. */
  80052. needAlphaBlending(): boolean;
  80053. /**
  80054. * Specifies if this material should be rendered in alpha test mode
  80055. * @returns false as the sky material doesn't need alpha testing.
  80056. */
  80057. needAlphaTesting(): boolean;
  80058. /**
  80059. * Get the texture used for alpha test purpose.
  80060. * @returns null as the sky material has no texture.
  80061. */
  80062. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80063. /**
  80064. * Get if the submesh is ready to be used and all its information available.
  80065. * Child classes can use it to update shaders
  80066. * @param mesh defines the mesh to check
  80067. * @param subMesh defines which submesh to check
  80068. * @param useInstances specifies that instances should be used
  80069. * @returns a boolean indicating that the submesh is ready or not
  80070. */
  80071. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80072. /**
  80073. * Binds the submesh to this material by preparing the effect and shader to draw
  80074. * @param world defines the world transformation matrix
  80075. * @param mesh defines the mesh containing the submesh
  80076. * @param subMesh defines the submesh to bind the material to
  80077. */
  80078. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80079. /**
  80080. * Get the list of animatables in the material.
  80081. * @returns the list of animatables object used in the material
  80082. */
  80083. getAnimatables(): BABYLON.IAnimatable[];
  80084. /**
  80085. * Disposes the material
  80086. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80087. */
  80088. dispose(forceDisposeEffect?: boolean): void;
  80089. /**
  80090. * Makes a duplicate of the material, and gives it a new name
  80091. * @param name defines the new name for the duplicated material
  80092. * @returns the cloned material
  80093. */
  80094. clone(name: string): SkyMaterial;
  80095. /**
  80096. * Serializes this material in a JSON representation
  80097. * @returns the serialized material object
  80098. */
  80099. serialize(): any;
  80100. /**
  80101. * Gets the current class name of the material e.g. "SkyMaterial"
  80102. * Mainly use in serialization.
  80103. * @returns the class name
  80104. */
  80105. getClassName(): string;
  80106. /**
  80107. * Creates a sky material from parsed material data
  80108. * @param source defines the JSON representation of the material
  80109. * @param scene defines the hosting scene
  80110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80111. * @returns a new sky material
  80112. */
  80113. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80114. }
  80115. }
  80116. declare module BABYLON {
  80117. /** @hidden */
  80118. export var terrainPixelShader: {
  80119. name: string;
  80120. shader: string;
  80121. };
  80122. }
  80123. declare module BABYLON {
  80124. /** @hidden */
  80125. export var terrainVertexShader: {
  80126. name: string;
  80127. shader: string;
  80128. };
  80129. }
  80130. declare module BABYLON {
  80131. export class TerrainMaterial extends BABYLON.PushMaterial {
  80132. private _mixTexture;
  80133. mixTexture: BABYLON.BaseTexture;
  80134. private _diffuseTexture1;
  80135. diffuseTexture1: BABYLON.Texture;
  80136. private _diffuseTexture2;
  80137. diffuseTexture2: BABYLON.Texture;
  80138. private _diffuseTexture3;
  80139. diffuseTexture3: BABYLON.Texture;
  80140. private _bumpTexture1;
  80141. bumpTexture1: BABYLON.Texture;
  80142. private _bumpTexture2;
  80143. bumpTexture2: BABYLON.Texture;
  80144. private _bumpTexture3;
  80145. bumpTexture3: BABYLON.Texture;
  80146. diffuseColor: BABYLON.Color3;
  80147. specularColor: BABYLON.Color3;
  80148. specularPower: number;
  80149. private _disableLighting;
  80150. disableLighting: boolean;
  80151. private _maxSimultaneousLights;
  80152. maxSimultaneousLights: number;
  80153. private _renderId;
  80154. constructor(name: string, scene: BABYLON.Scene);
  80155. needAlphaBlending(): boolean;
  80156. needAlphaTesting(): boolean;
  80157. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80158. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80159. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80160. getAnimatables(): BABYLON.IAnimatable[];
  80161. getActiveTextures(): BABYLON.BaseTexture[];
  80162. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80163. dispose(forceDisposeEffect?: boolean): void;
  80164. clone(name: string): TerrainMaterial;
  80165. serialize(): any;
  80166. getClassName(): string;
  80167. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80168. }
  80169. }
  80170. declare module BABYLON {
  80171. /** @hidden */
  80172. export var triplanarPixelShader: {
  80173. name: string;
  80174. shader: string;
  80175. };
  80176. }
  80177. declare module BABYLON {
  80178. /** @hidden */
  80179. export var triplanarVertexShader: {
  80180. name: string;
  80181. shader: string;
  80182. };
  80183. }
  80184. declare module BABYLON {
  80185. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80186. mixTexture: BABYLON.BaseTexture;
  80187. private _diffuseTextureX;
  80188. diffuseTextureX: BABYLON.BaseTexture;
  80189. private _diffuseTextureY;
  80190. diffuseTextureY: BABYLON.BaseTexture;
  80191. private _diffuseTextureZ;
  80192. diffuseTextureZ: BABYLON.BaseTexture;
  80193. private _normalTextureX;
  80194. normalTextureX: BABYLON.BaseTexture;
  80195. private _normalTextureY;
  80196. normalTextureY: BABYLON.BaseTexture;
  80197. private _normalTextureZ;
  80198. normalTextureZ: BABYLON.BaseTexture;
  80199. tileSize: number;
  80200. diffuseColor: BABYLON.Color3;
  80201. specularColor: BABYLON.Color3;
  80202. specularPower: number;
  80203. private _disableLighting;
  80204. disableLighting: boolean;
  80205. private _maxSimultaneousLights;
  80206. maxSimultaneousLights: number;
  80207. private _renderId;
  80208. constructor(name: string, scene: BABYLON.Scene);
  80209. needAlphaBlending(): boolean;
  80210. needAlphaTesting(): boolean;
  80211. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80212. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80213. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80214. getAnimatables(): BABYLON.IAnimatable[];
  80215. getActiveTextures(): BABYLON.BaseTexture[];
  80216. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80217. dispose(forceDisposeEffect?: boolean): void;
  80218. clone(name: string): TriPlanarMaterial;
  80219. serialize(): any;
  80220. getClassName(): string;
  80221. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80222. }
  80223. }
  80224. declare module BABYLON {
  80225. /** @hidden */
  80226. export var waterPixelShader: {
  80227. name: string;
  80228. shader: string;
  80229. };
  80230. }
  80231. declare module BABYLON {
  80232. /** @hidden */
  80233. export var waterVertexShader: {
  80234. name: string;
  80235. shader: string;
  80236. };
  80237. }
  80238. declare module BABYLON {
  80239. export class WaterMaterial extends BABYLON.PushMaterial {
  80240. renderTargetSize: BABYLON.Vector2;
  80241. private _bumpTexture;
  80242. bumpTexture: BABYLON.BaseTexture;
  80243. diffuseColor: BABYLON.Color3;
  80244. specularColor: BABYLON.Color3;
  80245. specularPower: number;
  80246. private _disableLighting;
  80247. disableLighting: boolean;
  80248. private _maxSimultaneousLights;
  80249. maxSimultaneousLights: number;
  80250. /**
  80251. * @param {number}: Represents the wind force
  80252. */
  80253. windForce: number;
  80254. /**
  80255. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80256. */
  80257. windDirection: BABYLON.Vector2;
  80258. /**
  80259. * @param {number}: Wave height, represents the height of the waves
  80260. */
  80261. waveHeight: number;
  80262. /**
  80263. * @param {number}: Bump height, represents the bump height related to the bump map
  80264. */
  80265. bumpHeight: number;
  80266. /**
  80267. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80268. */
  80269. private _bumpSuperimpose;
  80270. bumpSuperimpose: boolean;
  80271. /**
  80272. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80273. */
  80274. private _fresnelSeparate;
  80275. fresnelSeparate: boolean;
  80276. /**
  80277. * @param {boolean}: bump Waves modify the reflection.
  80278. */
  80279. private _bumpAffectsReflection;
  80280. bumpAffectsReflection: boolean;
  80281. /**
  80282. * @param {number}: The water color blended with the refraction (near)
  80283. */
  80284. waterColor: BABYLON.Color3;
  80285. /**
  80286. * @param {number}: The blend factor related to the water color
  80287. */
  80288. colorBlendFactor: number;
  80289. /**
  80290. * @param {number}: The water color blended with the reflection (far)
  80291. */
  80292. waterColor2: BABYLON.Color3;
  80293. /**
  80294. * @param {number}: The blend factor related to the water color (reflection, far)
  80295. */
  80296. colorBlendFactor2: number;
  80297. /**
  80298. * @param {number}: Represents the maximum length of a wave
  80299. */
  80300. waveLength: number;
  80301. /**
  80302. * @param {number}: Defines the waves speed
  80303. */
  80304. waveSpeed: number;
  80305. /**
  80306. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80307. * will avoid calculating useless pixels in the pixel shader of the water material.
  80308. */
  80309. disableClipPlane: boolean;
  80310. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80311. private _mesh;
  80312. private _refractionRTT;
  80313. private _reflectionRTT;
  80314. private _reflectionTransform;
  80315. private _lastTime;
  80316. private _lastDeltaTime;
  80317. private _renderId;
  80318. private _useLogarithmicDepth;
  80319. private _waitingRenderList;
  80320. private _imageProcessingConfiguration;
  80321. private _imageProcessingObserver;
  80322. /**
  80323. * Gets a boolean indicating that current material needs to register RTT
  80324. */
  80325. get hasRenderTargetTextures(): boolean;
  80326. /**
  80327. * Constructor
  80328. */
  80329. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80330. get useLogarithmicDepth(): boolean;
  80331. set useLogarithmicDepth(value: boolean);
  80332. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80333. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80334. addToRenderList(node: any): void;
  80335. enableRenderTargets(enable: boolean): void;
  80336. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80337. get renderTargetsEnabled(): boolean;
  80338. needAlphaBlending(): boolean;
  80339. needAlphaTesting(): boolean;
  80340. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80341. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80342. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80343. private _createRenderTargets;
  80344. getAnimatables(): BABYLON.IAnimatable[];
  80345. getActiveTextures(): BABYLON.BaseTexture[];
  80346. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80347. dispose(forceDisposeEffect?: boolean): void;
  80348. clone(name: string): WaterMaterial;
  80349. serialize(): any;
  80350. getClassName(): string;
  80351. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80352. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80353. }
  80354. }
  80355. declare module BABYLON {
  80356. /** @hidden */
  80357. export var asciiartPixelShader: {
  80358. name: string;
  80359. shader: string;
  80360. };
  80361. }
  80362. declare module BABYLON {
  80363. /**
  80364. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80365. *
  80366. * It basically takes care rendering the font front the given font size to a texture.
  80367. * This is used later on in the postprocess.
  80368. */
  80369. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80370. private _font;
  80371. private _text;
  80372. private _charSize;
  80373. /**
  80374. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80375. */
  80376. get charSize(): number;
  80377. /**
  80378. * Create a new instance of the Ascii Art FontTexture class
  80379. * @param name the name of the texture
  80380. * @param font the font to use, use the W3C CSS notation
  80381. * @param text the caracter set to use in the rendering.
  80382. * @param scene the scene that owns the texture
  80383. */
  80384. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80385. /**
  80386. * Gets the max char width of a font.
  80387. * @param font the font to use, use the W3C CSS notation
  80388. * @return the max char width
  80389. */
  80390. private getFontWidth;
  80391. /**
  80392. * Gets the max char height of a font.
  80393. * @param font the font to use, use the W3C CSS notation
  80394. * @return the max char height
  80395. */
  80396. private getFontHeight;
  80397. /**
  80398. * Clones the current AsciiArtTexture.
  80399. * @return the clone of the texture.
  80400. */
  80401. clone(): AsciiArtFontTexture;
  80402. /**
  80403. * Parses a json object representing the texture and returns an instance of it.
  80404. * @param source the source JSON representation
  80405. * @param scene the scene to create the texture for
  80406. * @return the parsed texture
  80407. */
  80408. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80409. }
  80410. /**
  80411. * Option available in the Ascii Art Post Process.
  80412. */
  80413. export interface IAsciiArtPostProcessOptions {
  80414. /**
  80415. * The font to use following the w3c font definition.
  80416. */
  80417. font?: string;
  80418. /**
  80419. * The character set to use in the postprocess.
  80420. */
  80421. characterSet?: string;
  80422. /**
  80423. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80424. * This number is defined between 0 and 1;
  80425. */
  80426. mixToTile?: number;
  80427. /**
  80428. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80429. * This number is defined between 0 and 1;
  80430. */
  80431. mixToNormal?: number;
  80432. }
  80433. /**
  80434. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80435. *
  80436. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80437. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80438. */
  80439. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80440. /**
  80441. * The font texture used to render the char in the post process.
  80442. */
  80443. private _asciiArtFontTexture;
  80444. /**
  80445. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80446. * This number is defined between 0 and 1;
  80447. */
  80448. mixToTile: number;
  80449. /**
  80450. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80451. * This number is defined between 0 and 1;
  80452. */
  80453. mixToNormal: number;
  80454. /**
  80455. * Instantiates a new Ascii Art Post Process.
  80456. * @param name the name to give to the postprocess
  80457. * @camera the camera to apply the post process to.
  80458. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80459. */
  80460. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80461. }
  80462. }
  80463. declare module BABYLON {
  80464. /** @hidden */
  80465. export var digitalrainPixelShader: {
  80466. name: string;
  80467. shader: string;
  80468. };
  80469. }
  80470. declare module BABYLON {
  80471. /**
  80472. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80473. *
  80474. * It basically takes care rendering the font front the given font size to a texture.
  80475. * This is used later on in the postprocess.
  80476. */
  80477. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80478. private _font;
  80479. private _text;
  80480. private _charSize;
  80481. /**
  80482. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80483. */
  80484. get charSize(): number;
  80485. /**
  80486. * Create a new instance of the Digital Rain FontTexture class
  80487. * @param name the name of the texture
  80488. * @param font the font to use, use the W3C CSS notation
  80489. * @param text the caracter set to use in the rendering.
  80490. * @param scene the scene that owns the texture
  80491. */
  80492. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80493. /**
  80494. * Gets the max char width of a font.
  80495. * @param font the font to use, use the W3C CSS notation
  80496. * @return the max char width
  80497. */
  80498. private getFontWidth;
  80499. /**
  80500. * Gets the max char height of a font.
  80501. * @param font the font to use, use the W3C CSS notation
  80502. * @return the max char height
  80503. */
  80504. private getFontHeight;
  80505. /**
  80506. * Clones the current DigitalRainFontTexture.
  80507. * @return the clone of the texture.
  80508. */
  80509. clone(): DigitalRainFontTexture;
  80510. /**
  80511. * Parses a json object representing the texture and returns an instance of it.
  80512. * @param source the source JSON representation
  80513. * @param scene the scene to create the texture for
  80514. * @return the parsed texture
  80515. */
  80516. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80517. }
  80518. /**
  80519. * Option available in the Digital Rain Post Process.
  80520. */
  80521. export interface IDigitalRainPostProcessOptions {
  80522. /**
  80523. * The font to use following the w3c font definition.
  80524. */
  80525. font?: string;
  80526. /**
  80527. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80528. * This number is defined between 0 and 1;
  80529. */
  80530. mixToTile?: number;
  80531. /**
  80532. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80533. * This number is defined between 0 and 1;
  80534. */
  80535. mixToNormal?: number;
  80536. }
  80537. /**
  80538. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80539. *
  80540. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80541. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80542. */
  80543. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80544. /**
  80545. * The font texture used to render the char in the post process.
  80546. */
  80547. private _digitalRainFontTexture;
  80548. /**
  80549. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80550. * This number is defined between 0 and 1;
  80551. */
  80552. mixToTile: number;
  80553. /**
  80554. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80555. * This number is defined between 0 and 1;
  80556. */
  80557. mixToNormal: number;
  80558. /**
  80559. * Instantiates a new Digital Rain Post Process.
  80560. * @param name the name to give to the postprocess
  80561. * @camera the camera to apply the post process to.
  80562. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80563. */
  80564. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80565. }
  80566. }
  80567. declare module BABYLON {
  80568. /** @hidden */
  80569. export var brickProceduralTexturePixelShader: {
  80570. name: string;
  80571. shader: string;
  80572. };
  80573. }
  80574. declare module BABYLON {
  80575. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80576. private _numberOfBricksHeight;
  80577. private _numberOfBricksWidth;
  80578. private _jointColor;
  80579. private _brickColor;
  80580. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80581. updateShaderUniforms(): void;
  80582. get numberOfBricksHeight(): number;
  80583. set numberOfBricksHeight(value: number);
  80584. get numberOfBricksWidth(): number;
  80585. set numberOfBricksWidth(value: number);
  80586. get jointColor(): BABYLON.Color3;
  80587. set jointColor(value: BABYLON.Color3);
  80588. get brickColor(): BABYLON.Color3;
  80589. set brickColor(value: BABYLON.Color3);
  80590. /**
  80591. * Serializes this brick procedural texture
  80592. * @returns a serialized brick procedural texture object
  80593. */
  80594. serialize(): any;
  80595. /**
  80596. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80597. * @param parsedTexture defines parsed texture data
  80598. * @param scene defines the current scene
  80599. * @param rootUrl defines the root URL containing brick procedural texture information
  80600. * @returns a parsed Brick Procedural BABYLON.Texture
  80601. */
  80602. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80603. }
  80604. }
  80605. declare module BABYLON {
  80606. /** @hidden */
  80607. export var cloudProceduralTexturePixelShader: {
  80608. name: string;
  80609. shader: string;
  80610. };
  80611. }
  80612. declare module BABYLON {
  80613. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80614. private _skyColor;
  80615. private _cloudColor;
  80616. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80617. updateShaderUniforms(): void;
  80618. get skyColor(): BABYLON.Color4;
  80619. set skyColor(value: BABYLON.Color4);
  80620. get cloudColor(): BABYLON.Color4;
  80621. set cloudColor(value: BABYLON.Color4);
  80622. /**
  80623. * Serializes this cloud procedural texture
  80624. * @returns a serialized cloud procedural texture object
  80625. */
  80626. serialize(): any;
  80627. /**
  80628. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80629. * @param parsedTexture defines parsed texture data
  80630. * @param scene defines the current scene
  80631. * @param rootUrl defines the root URL containing cloud procedural texture information
  80632. * @returns a parsed Cloud Procedural BABYLON.Texture
  80633. */
  80634. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80635. }
  80636. }
  80637. declare module BABYLON {
  80638. /** @hidden */
  80639. export var fireProceduralTexturePixelShader: {
  80640. name: string;
  80641. shader: string;
  80642. };
  80643. }
  80644. declare module BABYLON {
  80645. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80646. private _time;
  80647. private _speed;
  80648. private _autoGenerateTime;
  80649. private _fireColors;
  80650. private _alphaThreshold;
  80651. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80652. updateShaderUniforms(): void;
  80653. render(useCameraPostProcess?: boolean): void;
  80654. static get PurpleFireColors(): BABYLON.Color3[];
  80655. static get GreenFireColors(): BABYLON.Color3[];
  80656. static get RedFireColors(): BABYLON.Color3[];
  80657. static get BlueFireColors(): BABYLON.Color3[];
  80658. get autoGenerateTime(): boolean;
  80659. set autoGenerateTime(value: boolean);
  80660. get fireColors(): BABYLON.Color3[];
  80661. set fireColors(value: BABYLON.Color3[]);
  80662. get time(): number;
  80663. set time(value: number);
  80664. get speed(): BABYLON.Vector2;
  80665. set speed(value: BABYLON.Vector2);
  80666. get alphaThreshold(): number;
  80667. set alphaThreshold(value: number);
  80668. /**
  80669. * Serializes this fire procedural texture
  80670. * @returns a serialized fire procedural texture object
  80671. */
  80672. serialize(): any;
  80673. /**
  80674. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80675. * @param parsedTexture defines parsed texture data
  80676. * @param scene defines the current scene
  80677. * @param rootUrl defines the root URL containing fire procedural texture information
  80678. * @returns a parsed Fire Procedural BABYLON.Texture
  80679. */
  80680. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80681. }
  80682. }
  80683. declare module BABYLON {
  80684. /** @hidden */
  80685. export var grassProceduralTexturePixelShader: {
  80686. name: string;
  80687. shader: string;
  80688. };
  80689. }
  80690. declare module BABYLON {
  80691. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80692. private _grassColors;
  80693. private _groundColor;
  80694. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80695. updateShaderUniforms(): void;
  80696. get grassColors(): BABYLON.Color3[];
  80697. set grassColors(value: BABYLON.Color3[]);
  80698. get groundColor(): BABYLON.Color3;
  80699. set groundColor(value: BABYLON.Color3);
  80700. /**
  80701. * Serializes this grass procedural texture
  80702. * @returns a serialized grass procedural texture object
  80703. */
  80704. serialize(): any;
  80705. /**
  80706. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80707. * @param parsedTexture defines parsed texture data
  80708. * @param scene defines the current scene
  80709. * @param rootUrl defines the root URL containing grass procedural texture information
  80710. * @returns a parsed Grass Procedural BABYLON.Texture
  80711. */
  80712. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80713. }
  80714. }
  80715. declare module BABYLON {
  80716. /** @hidden */
  80717. export var marbleProceduralTexturePixelShader: {
  80718. name: string;
  80719. shader: string;
  80720. };
  80721. }
  80722. declare module BABYLON {
  80723. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80724. private _numberOfTilesHeight;
  80725. private _numberOfTilesWidth;
  80726. private _amplitude;
  80727. private _jointColor;
  80728. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80729. updateShaderUniforms(): void;
  80730. get numberOfTilesHeight(): number;
  80731. set numberOfTilesHeight(value: number);
  80732. get amplitude(): number;
  80733. set amplitude(value: number);
  80734. get numberOfTilesWidth(): number;
  80735. set numberOfTilesWidth(value: number);
  80736. get jointColor(): BABYLON.Color3;
  80737. set jointColor(value: BABYLON.Color3);
  80738. /**
  80739. * Serializes this marble procedural texture
  80740. * @returns a serialized marble procedural texture object
  80741. */
  80742. serialize(): any;
  80743. /**
  80744. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80745. * @param parsedTexture defines parsed texture data
  80746. * @param scene defines the current scene
  80747. * @param rootUrl defines the root URL containing marble procedural texture information
  80748. * @returns a parsed Marble Procedural BABYLON.Texture
  80749. */
  80750. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80751. }
  80752. }
  80753. declare module BABYLON {
  80754. /** @hidden */
  80755. export var normalMapProceduralTexturePixelShader: {
  80756. name: string;
  80757. shader: string;
  80758. };
  80759. }
  80760. declare module BABYLON {
  80761. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80762. private _baseTexture;
  80763. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80764. updateShaderUniforms(): void;
  80765. render(useCameraPostProcess?: boolean): void;
  80766. resize(size: any, generateMipMaps: any): void;
  80767. get baseTexture(): BABYLON.Texture;
  80768. set baseTexture(texture: BABYLON.Texture);
  80769. /**
  80770. * Serializes this normal map procedural texture
  80771. * @returns a serialized normal map procedural texture object
  80772. */
  80773. serialize(): any;
  80774. /**
  80775. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80776. * @param parsedTexture defines parsed texture data
  80777. * @param scene defines the current scene
  80778. * @param rootUrl defines the root URL containing normal map procedural texture information
  80779. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80780. */
  80781. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80782. }
  80783. }
  80784. declare module BABYLON {
  80785. /** @hidden */
  80786. export var perlinNoiseProceduralTexturePixelShader: {
  80787. name: string;
  80788. shader: string;
  80789. };
  80790. }
  80791. declare module BABYLON {
  80792. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80793. time: number;
  80794. timeScale: number;
  80795. translationSpeed: number;
  80796. private _currentTranslation;
  80797. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80798. updateShaderUniforms(): void;
  80799. render(useCameraPostProcess?: boolean): void;
  80800. resize(size: any, generateMipMaps: any): void;
  80801. /**
  80802. * Serializes this perlin noise procedural texture
  80803. * @returns a serialized perlin noise procedural texture object
  80804. */
  80805. serialize(): any;
  80806. /**
  80807. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80808. * @param parsedTexture defines parsed texture data
  80809. * @param scene defines the current scene
  80810. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80811. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80812. */
  80813. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80814. }
  80815. }
  80816. declare module BABYLON {
  80817. /** @hidden */
  80818. export var roadProceduralTexturePixelShader: {
  80819. name: string;
  80820. shader: string;
  80821. };
  80822. }
  80823. declare module BABYLON {
  80824. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80825. private _roadColor;
  80826. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80827. updateShaderUniforms(): void;
  80828. get roadColor(): BABYLON.Color3;
  80829. set roadColor(value: BABYLON.Color3);
  80830. /**
  80831. * Serializes this road procedural texture
  80832. * @returns a serialized road procedural texture object
  80833. */
  80834. serialize(): any;
  80835. /**
  80836. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80837. * @param parsedTexture defines parsed texture data
  80838. * @param scene defines the current scene
  80839. * @param rootUrl defines the root URL containing road procedural texture information
  80840. * @returns a parsed Road Procedural BABYLON.Texture
  80841. */
  80842. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80843. }
  80844. }
  80845. declare module BABYLON {
  80846. /** @hidden */
  80847. export var starfieldProceduralTexturePixelShader: {
  80848. name: string;
  80849. shader: string;
  80850. };
  80851. }
  80852. declare module BABYLON {
  80853. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80854. private _time;
  80855. private _alpha;
  80856. private _beta;
  80857. private _zoom;
  80858. private _formuparam;
  80859. private _stepsize;
  80860. private _tile;
  80861. private _brightness;
  80862. private _darkmatter;
  80863. private _distfading;
  80864. private _saturation;
  80865. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80866. updateShaderUniforms(): void;
  80867. get time(): number;
  80868. set time(value: number);
  80869. get alpha(): number;
  80870. set alpha(value: number);
  80871. get beta(): number;
  80872. set beta(value: number);
  80873. get formuparam(): number;
  80874. set formuparam(value: number);
  80875. get stepsize(): number;
  80876. set stepsize(value: number);
  80877. get zoom(): number;
  80878. set zoom(value: number);
  80879. get tile(): number;
  80880. set tile(value: number);
  80881. get brightness(): number;
  80882. set brightness(value: number);
  80883. get darkmatter(): number;
  80884. set darkmatter(value: number);
  80885. get distfading(): number;
  80886. set distfading(value: number);
  80887. get saturation(): number;
  80888. set saturation(value: number);
  80889. /**
  80890. * Serializes this starfield procedural texture
  80891. * @returns a serialized starfield procedural texture object
  80892. */
  80893. serialize(): any;
  80894. /**
  80895. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80896. * @param parsedTexture defines parsed texture data
  80897. * @param scene defines the current scene
  80898. * @param rootUrl defines the root URL containing startfield procedural texture information
  80899. * @returns a parsed Starfield Procedural BABYLON.Texture
  80900. */
  80901. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80902. }
  80903. }
  80904. declare module BABYLON {
  80905. /** @hidden */
  80906. export var woodProceduralTexturePixelShader: {
  80907. name: string;
  80908. shader: string;
  80909. };
  80910. }
  80911. declare module BABYLON {
  80912. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80913. private _ampScale;
  80914. private _woodColor;
  80915. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80916. updateShaderUniforms(): void;
  80917. get ampScale(): number;
  80918. set ampScale(value: number);
  80919. get woodColor(): BABYLON.Color3;
  80920. set woodColor(value: BABYLON.Color3);
  80921. /**
  80922. * Serializes this wood procedural texture
  80923. * @returns a serialized wood procedural texture object
  80924. */
  80925. serialize(): any;
  80926. /**
  80927. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80928. * @param parsedTexture defines parsed texture data
  80929. * @param scene defines the current scene
  80930. * @param rootUrl defines the root URL containing wood procedural texture information
  80931. * @returns a parsed Wood Procedural BABYLON.Texture
  80932. */
  80933. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80934. }
  80935. }